LLVM  4.0.0
ConstantsContext.h
Go to the documentation of this file.
1 //===-- ConstantsContext.h - Constants-related Context Interals -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines various helper methods and classes used by
11 // LLVMContextImpl for creating and managing constants.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_IR_CONSTANTSCONTEXT_H
16 #define LLVM_LIB_IR_CONSTANTSCONTEXT_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/DenseMapInfo.h"
20 #include "llvm/ADT/DenseSet.h"
21 #include "llvm/ADT/Hashing.h"
22 #include "llvm/ADT/None.h"
23 #include "llvm/ADT/SmallVector.h"
24 #include "llvm/ADT/StringRef.h"
25 #include "llvm/IR/Constants.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/InlineAsm.h"
28 #include "llvm/IR/Instruction.h"
29 #include "llvm/IR/OperandTraits.h"
30 #include "llvm/Support/Casting.h"
31 #include "llvm/Support/Debug.h"
34 #include <cassert>
35 #include <cstddef>
36 #include <cstdint>
37 #include <utility>
38 
39 #define DEBUG_TYPE "ir"
40 
41 namespace llvm {
42 
43 /// UnaryConstantExpr - This class is private to Constants.cpp, and is used
44 /// behind the scenes to implement unary constant exprs.
46  void anchor() override;
47 
48 public:
49  UnaryConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
50  : ConstantExpr(Ty, Opcode, &Op<0>(), 1) {
51  Op<0>() = C;
52  }
53 
54  // allocate space for exactly one operand
55  void *operator new(size_t s) {
56  return User::operator new(s, 1);
57  }
58 
59  void *operator new(size_t, unsigned) = delete;
60 
62 };
63 
64 /// BinaryConstantExpr - This class is private to Constants.cpp, and is used
65 /// behind the scenes to implement binary constant exprs.
67  void anchor() override;
68 
69 public:
70  BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2,
71  unsigned Flags)
72  : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) {
73  Op<0>() = C1;
74  Op<1>() = C2;
76  }
77 
78  // allocate space for exactly two operands
79  void *operator new(size_t s) {
80  return User::operator new(s, 2);
81  }
82 
83  void *operator new(size_t, unsigned) = delete;
84 
85  /// Transparently provide more efficient getOperand methods.
87 };
88 
89 /// SelectConstantExpr - This class is private to Constants.cpp, and is used
90 /// behind the scenes to implement select constant exprs.
92  void anchor() override;
93 
94 public:
96  : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) {
97  Op<0>() = C1;
98  Op<1>() = C2;
99  Op<2>() = C3;
100  }
101 
102  // allocate space for exactly three operands
103  void *operator new(size_t s) {
104  return User::operator new(s, 3);
105  }
106 
107  void *operator new(size_t, unsigned) = delete;
108 
109  /// Transparently provide more efficient getOperand methods.
111 };
112 
113 /// ExtractElementConstantExpr - This class is private to
114 /// Constants.cpp, and is used behind the scenes to implement
115 /// extractelement constant exprs.
117  void anchor() override;
118 
119 public:
121  : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
122  Instruction::ExtractElement, &Op<0>(), 2) {
123  Op<0>() = C1;
124  Op<1>() = C2;
125  }
126 
127  // allocate space for exactly two operands
128  void *operator new(size_t s) {
129  return User::operator new(s, 2);
130  }
131 
132  void *operator new(size_t, unsigned) = delete;
133 
134  /// Transparently provide more efficient getOperand methods.
136 };
137 
138 /// InsertElementConstantExpr - This class is private to
139 /// Constants.cpp, and is used behind the scenes to implement
140 /// insertelement constant exprs.
142  void anchor() override;
143 
144 public:
146  : ConstantExpr(C1->getType(), Instruction::InsertElement,
147  &Op<0>(), 3) {
148  Op<0>() = C1;
149  Op<1>() = C2;
150  Op<2>() = C3;
151  }
152 
153  // allocate space for exactly three operands
154  void *operator new(size_t s) {
155  return User::operator new(s, 3);
156  }
157 
158  void *operator new(size_t, unsigned) = delete;
159 
160  /// Transparently provide more efficient getOperand methods.
162 };
163 
164 /// ShuffleVectorConstantExpr - This class is private to
165 /// Constants.cpp, and is used behind the scenes to implement
166 /// shufflevector constant exprs.
168  void anchor() override;
169 
170 public:
173  cast<VectorType>(C1->getType())->getElementType(),
174  cast<VectorType>(C3->getType())->getNumElements()),
175  Instruction::ShuffleVector,
176  &Op<0>(), 3) {
177  Op<0>() = C1;
178  Op<1>() = C2;
179  Op<2>() = C3;
180  }
181 
182  // allocate space for exactly three operands
183  void *operator new(size_t s) {
184  return User::operator new(s, 3);
185  }
186 
187  void *operator new(size_t, unsigned) = delete;
188 
189  /// Transparently provide more efficient getOperand methods.
191 };
192 
193 /// ExtractValueConstantExpr - This class is private to
194 /// Constants.cpp, and is used behind the scenes to implement
195 /// extractvalue constant exprs.
197  void anchor() override;
198 
199 public:
201  Type *DestTy)
202  : ConstantExpr(DestTy, Instruction::ExtractValue, &Op<0>(), 1),
203  Indices(IdxList.begin(), IdxList.end()) {
204  Op<0>() = Agg;
205  }
206 
207  // allocate space for exactly one operand
208  void *operator new(size_t s) {
209  return User::operator new(s, 1);
210  }
211 
212  void *operator new(size_t, unsigned) = delete;
213 
214  /// Indices - These identify which value to extract.
216 
217  /// Transparently provide more efficient getOperand methods.
219 
220  static bool classof(const ConstantExpr *CE) {
221  return CE->getOpcode() == Instruction::ExtractValue;
222  }
223  static bool classof(const Value *V) {
224  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
225  }
226 };
227 
228 /// InsertValueConstantExpr - This class is private to
229 /// Constants.cpp, and is used behind the scenes to implement
230 /// insertvalue constant exprs.
232  void anchor() override;
233 
234 public:
236  ArrayRef<unsigned> IdxList, Type *DestTy)
237  : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2),
238  Indices(IdxList.begin(), IdxList.end()) {
239  Op<0>() = Agg;
240  Op<1>() = Val;
241  }
242 
243  // allocate space for exactly one operand
244  void *operator new(size_t s) {
245  return User::operator new(s, 2);
246  }
247 
248  void *operator new(size_t, unsigned) = delete;
249 
250  /// Indices - These identify the position for the insertion.
252 
253  /// Transparently provide more efficient getOperand methods.
255 
256  static bool classof(const ConstantExpr *CE) {
257  return CE->getOpcode() == Instruction::InsertValue;
258  }
259  static bool classof(const Value *V) {
260  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
261  }
262 };
263 
264 /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
265 /// used behind the scenes to implement getelementpr constant exprs.
267  Type *SrcElementTy;
268  Type *ResElementTy;
269 
270  GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C,
271  ArrayRef<Constant *> IdxList, Type *DestTy);
272 
273  void anchor() override;
274 
275 public:
276  static GetElementPtrConstantExpr *Create(Type *SrcElementTy, Constant *C,
277  ArrayRef<Constant *> IdxList,
278  Type *DestTy, unsigned Flags) {
279  GetElementPtrConstantExpr *Result = new (IdxList.size() + 1)
280  GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy);
281  Result->SubclassOptionalData = Flags;
282  return Result;
283  }
284 
285  Type *getSourceElementType() const;
286  Type *getResultElementType() const;
287 
288  /// Transparently provide more efficient getOperand methods.
290 
291  static bool classof(const ConstantExpr *CE) {
292  return CE->getOpcode() == Instruction::GetElementPtr;
293  }
294  static bool classof(const Value *V) {
295  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
296  }
297 };
298 
299 // CompareConstantExpr - This class is private to Constants.cpp, and is used
300 // behind the scenes to implement ICmp and FCmp constant expressions. This is
301 // needed in order to store the predicate value for these instructions.
303  void anchor() override;
304 
305 public:
306  unsigned short predicate;
308  unsigned short pred, Constant* LHS, Constant* RHS)
309  : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) {
310  Op<0>() = LHS;
311  Op<1>() = RHS;
312  }
313 
314  // allocate space for exactly two operands
315  void *operator new(size_t s) {
316  return User::operator new(s, 2);
317  }
318 
319  void *operator new(size_t, unsigned) = delete;
320 
321  /// Transparently provide more efficient getOperand methods.
323 
324  static bool classof(const ConstantExpr *CE) {
325  return CE->getOpcode() == Instruction::ICmp ||
326  CE->getOpcode() == Instruction::FCmp;
327  }
328  static bool classof(const Value *V) {
329  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
330  }
331 };
332 
333 template <>
335  : public FixedNumOperandTraits<UnaryConstantExpr, 1> {};
337 
338 template <>
342 
343 template <>
347 
348 template <>
352 
353 template <>
357 
358 template <>
362 
363 template <>
367 
368 template <>
372 
373 template <>
376 
378 
379 template <>
383 
384 template <class ConstantClass> struct ConstantAggrKeyType;
385 struct InlineAsmKeyType;
386 struct ConstantExprKeyType;
387 
388 template <class ConstantClass> struct ConstantInfo;
389 template <> struct ConstantInfo<ConstantExpr> {
390  typedef ConstantExprKeyType ValType;
391  typedef Type TypeClass;
392 };
393 template <> struct ConstantInfo<InlineAsm> {
396 };
397 template <> struct ConstantInfo<ConstantArray> {
400 };
401 template <> struct ConstantInfo<ConstantStruct> {
404 };
405 template <> struct ConstantInfo<ConstantVector> {
408 };
409 
410 template <class ConstantClass> struct ConstantAggrKeyType {
414  : Operands(Operands) {}
415  ConstantAggrKeyType(const ConstantClass *C,
416  SmallVectorImpl<Constant *> &Storage) {
417  assert(Storage.empty() && "Expected empty storage");
418  for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
419  Storage.push_back(C->getOperand(I));
420  Operands = Storage;
421  }
422 
423  bool operator==(const ConstantAggrKeyType &X) const {
424  return Operands == X.Operands;
425  }
426 
427  bool operator==(const ConstantClass *C) const {
428  if (Operands.size() != C->getNumOperands())
429  return false;
430  for (unsigned I = 0, E = Operands.size(); I != E; ++I)
431  if (Operands[I] != C->getOperand(I))
432  return false;
433  return true;
434  }
435 
436  unsigned getHash() const {
437  return hash_combine_range(Operands.begin(), Operands.end());
438  }
439 
441  ConstantClass *create(TypeClass *Ty) const {
442  return new (Operands.size()) ConstantClass(Ty, Operands);
443  }
444 };
445 
453 
457  : AsmString(AsmString), Constraints(Constraints), FTy(FTy),
458  HasSideEffects(HasSideEffects), IsAlignStack(IsAlignStack),
459  AsmDialect(AsmDialect) {}
461  : AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()),
462  FTy(Asm->getFunctionType()), HasSideEffects(Asm->hasSideEffects()),
463  IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()) {}
464 
465  bool operator==(const InlineAsmKeyType &X) const {
466  return HasSideEffects == X.HasSideEffects &&
469  FTy == X.FTy;
470  }
471 
472  bool operator==(const InlineAsm *Asm) const {
473  return HasSideEffects == Asm->hasSideEffects() &&
474  IsAlignStack == Asm->isAlignStack() &&
475  AsmDialect == Asm->getDialect() &&
476  AsmString == Asm->getAsmString() &&
477  Constraints == Asm->getConstraintString() &&
478  FTy == Asm->getFunctionType();
479  }
480 
481  unsigned getHash() const {
483  AsmDialect, FTy);
484  }
485 
487  InlineAsm *create(TypeClass *Ty) const {
491  }
492 };
493 
495  uint8_t Opcode;
497  uint16_t SubclassData;
501 
503  unsigned short SubclassData = 0,
504  unsigned short SubclassOptionalData = 0,
506  Type *ExplicitTy = nullptr)
507  : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData),
511  : Opcode(CE->getOpcode()),
512  SubclassOptionalData(CE->getRawSubclassOptionalData()),
513  SubclassData(CE->isCompare() ? CE->getPredicate() : 0), Ops(Operands),
514  Indexes(CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()) {}
517  : Opcode(CE->getOpcode()),
518  SubclassOptionalData(CE->getRawSubclassOptionalData()),
519  SubclassData(CE->isCompare() ? CE->getPredicate() : 0),
520  Indexes(CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()) {
521  assert(Storage.empty() && "Expected empty storage");
522  for (unsigned I = 0, E = CE->getNumOperands(); I != E; ++I)
523  Storage.push_back(CE->getOperand(I));
524  Ops = Storage;
525  }
526 
527  bool operator==(const ConstantExprKeyType &X) const {
528  return Opcode == X.Opcode && SubclassData == X.SubclassData &&
530  Indexes == X.Indexes;
531  }
532 
533  bool operator==(const ConstantExpr *CE) const {
534  if (Opcode != CE->getOpcode())
535  return false;
537  return false;
538  if (Ops.size() != CE->getNumOperands())
539  return false;
540  if (SubclassData != (CE->isCompare() ? CE->getPredicate() : 0))
541  return false;
542  for (unsigned I = 0, E = Ops.size(); I != E; ++I)
543  if (Ops[I] != CE->getOperand(I))
544  return false;
545  if (Indexes != (CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()))
546  return false;
547  return true;
548  }
549 
550  unsigned getHash() const {
552  hash_combine_range(Ops.begin(), Ops.end()),
554  }
555 
558  switch (Opcode) {
559  default:
561  return new UnaryConstantExpr(Opcode, Ops[0], Ty);
562  if ((Opcode >= Instruction::BinaryOpsBegin &&
563  Opcode < Instruction::BinaryOpsEnd))
564  return new BinaryConstantExpr(Opcode, Ops[0], Ops[1],
566  llvm_unreachable("Invalid ConstantExpr!");
567  case Instruction::Select:
568  return new SelectConstantExpr(Ops[0], Ops[1], Ops[2]);
569  case Instruction::ExtractElement:
570  return new ExtractElementConstantExpr(Ops[0], Ops[1]);
571  case Instruction::InsertElement:
572  return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]);
573  case Instruction::ShuffleVector:
574  return new ShuffleVectorConstantExpr(Ops[0], Ops[1], Ops[2]);
575  case Instruction::InsertValue:
576  return new InsertValueConstantExpr(Ops[0], Ops[1], Indexes, Ty);
577  case Instruction::ExtractValue:
578  return new ExtractValueConstantExpr(Ops[0], Indexes, Ty);
579  case Instruction::GetElementPtr:
582  : cast<PointerType>(Ops[0]->getType()->getScalarType())
583  ->getElementType(),
584  Ops[0], Ops.slice(1), Ty, SubclassOptionalData);
585  case Instruction::ICmp:
586  return new CompareConstantExpr(Ty, Instruction::ICmp, SubclassData,
587  Ops[0], Ops[1]);
588  case Instruction::FCmp:
589  return new CompareConstantExpr(Ty, Instruction::FCmp, SubclassData,
590  Ops[0], Ops[1]);
591  }
592  }
593 };
594 
595 template <class ConstantClass> class ConstantUniqueMap {
596 public:
599  typedef std::pair<TypeClass *, ValType> LookupKey;
600 
601  /// Key and hash together, so that we compute the hash only once and reuse it.
602  typedef std::pair<unsigned, LookupKey> LookupKeyHashed;
603 
604 private:
605  struct MapInfo {
606  typedef DenseMapInfo<ConstantClass *> ConstantClassInfo;
607  static inline ConstantClass *getEmptyKey() {
608  return ConstantClassInfo::getEmptyKey();
609  }
610 
611  static inline ConstantClass *getTombstoneKey() {
612  return ConstantClassInfo::getTombstoneKey();
613  }
614 
615  static unsigned getHashValue(const ConstantClass *CP) {
617  return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage)));
618  }
619 
620  static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
621  return LHS == RHS;
622  }
623 
624  static unsigned getHashValue(const LookupKey &Val) {
625  return hash_combine(Val.first, Val.second.getHash());
626  }
627 
628  static unsigned getHashValue(const LookupKeyHashed &Val) {
629  return Val.first;
630  }
631 
632  static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
633  if (RHS == getEmptyKey() || RHS == getTombstoneKey())
634  return false;
635  if (LHS.first != RHS->getType())
636  return false;
637  return LHS.second == RHS;
638  }
639 
640  static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) {
641  return isEqual(LHS.second, RHS);
642  }
643  };
644 
645 public:
647 
648 private:
649  MapTy Map;
650 
651 public:
652  typename MapTy::iterator begin() { return Map.begin(); }
653  typename MapTy::iterator end() { return Map.end(); }
654 
655  void freeConstants() {
656  for (auto &I : Map)
657  delete I; // Asserts that use_empty().
658  }
659 
660 private:
661  ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) {
662  ConstantClass *Result = V.create(Ty);
663 
664  assert(Result->getType() == Ty && "Type specified is not correct!");
665  Map.insert_as(Result, HashKey);
666 
667  return Result;
668  }
669 
670 public:
671  /// Return the specified constant from the map, creating it if necessary.
672  ConstantClass *getOrCreate(TypeClass *Ty, ValType V) {
673  LookupKey Key(Ty, V);
674  /// Hash once, and reuse it for the lookup and the insertion if needed.
675  LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
676 
677  ConstantClass *Result = nullptr;
678 
679  auto I = Map.find_as(Lookup);
680  if (I == Map.end())
681  Result = create(Ty, V, Lookup);
682  else
683  Result = *I;
684  assert(Result && "Unexpected nullptr");
685 
686  return Result;
687  }
688 
689  /// Remove this constant from the map
690  void remove(ConstantClass *CP) {
691  typename MapTy::iterator I = Map.find(CP);
692  assert(I != Map.end() && "Constant not found in constant table!");
693  assert(*I == CP && "Didn't find correct element?");
694  Map.erase(I);
695  }
696 
698  ConstantClass *CP, Value *From,
699  Constant *To, unsigned NumUpdated = 0,
700  unsigned OperandNo = ~0u) {
701  LookupKey Key(CP->getType(), ValType(Operands, CP));
702  /// Hash once, and reuse it for the lookup and the insertion if needed.
703  LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
704 
705  auto I = Map.find_as(Lookup);
706  if (I != Map.end())
707  return *I;
708 
709  // Update to the new value. Optimize for the case when we have a single
710  // operand that we're changing, but handle bulk updates efficiently.
711  remove(CP);
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);
716  } else {
717  for (unsigned I = 0, E = CP->getNumOperands(); I != E; ++I)
718  if (CP->getOperand(I) == From)
719  CP->setOperand(I, To);
720  }
721  Map.insert_as(CP, Lookup);
722  return nullptr;
723  }
724 
725  void dump() const { DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n"); }
726 };
727 
728 } // end namespace llvm
729 
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
ConstantAggrKeyType< ConstantArray > ValType
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:241
AsmDialect getDialect() const
Definition: InlineAsm.h:70
ConstantInfo< InlineAsm >::TypeClass TypeClass
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)
Definition: DenseSet.h:146
static bool classof(const ConstantExpr *CE)
unsigned getNumOperands() const
Definition: User.h:167
ExtractValueConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to i...
iterator end() const
Definition: ArrayRef.h:130
bool operator==(const InlineAsmKeyType &X) const
const std::string & getAsmString() const
Definition: InlineAsm.h:82
Type * getResultElementType() const
Definition: Constants.cpp:2281
ConstantAggrKeyType(ArrayRef< Constant * > Operands, const ConstantClass *)
ShuffleVectorConstantExpr - 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.
bool erase(const ValueT &V)
Definition: DenseSet.h:85
const_iterator begin(StringRef path)
Get begin iterator over path.
Definition: Path.cpp:233
const std::string & getConstraintString() const
Definition: InlineAsm.h:83
ExtractElementConstantExpr(Constant *C1, Constant *C2)
const SmallVector< unsigned, 4 > Indices
Indices - These identify which value to extract.
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.
Definition: Function.cpp:905
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.
Definition: Constants.h:1182
DenseSet< ConstantClass *, MapInfo > MapTy
MapTy::iterator begin()
ConstantInfo< ConstantClass >::TypeClass TypeClass
bool isCast() const
Definition: Instruction.h:117
ConstantExprKeyType(const ConstantExpr *CE, SmallVectorImpl< Constant * > &Storage)
struct fuzzer::@269 Flags
Class to represent struct types.
Definition: DerivedTypes.h:199
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...
Definition: APFloat.h:32
CompareConstantExpr(Type *ty, Instruction::OtherOps opc, unsigned short pred, Constant *LHS, Constant *RHS)
ExtractValueConstantExpr(Constant *Agg, ArrayRef< unsigned > IdxList, Type *DestTy)
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:60
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. ...
Definition: Constants.cpp:1728
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Class to represent function types.
Definition: DerivedTypes.h:102
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:873
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
static bool classof(const ConstantExpr *CE)
Class to represent array types.
Definition: DerivedTypes.h:345
static bool classof(const Value *V)
bool operator==(const ConstantExprKeyType &X) const
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:141
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Definition: Casting.h:221
Class to represent pointers.
Definition: DerivedTypes.h:443
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
unsigned getHash() const
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...
Definition: DenseSet.h:181
bool hasSideEffects() const
Definition: InlineAsm.h:68
InlineAsmKeyType(const InlineAsm *Asm, SmallVectorImpl< Constant * > &)
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
ConstantClass * create(TypeClass *Ty) const
ArrayRef< Constant * > Ops
This is an important base class in LLVM.
Definition: Constant.h:42
bool hasIndices() const
Return true if this is an insertvalue or extractvalue expression, and the getIndices() method may be ...
Definition: Constants.cpp:1090
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.
Definition: DenseSet.h:157
bool operator==(const ConstantExpr *CE) const
static bool classof(const Value *V)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
iterator begin() const
Definition: ArrayRef.h:129
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
Value * getOperand(unsigned i) const
Definition: User.h:145
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.
Definition: Constants.h:490
unsigned getPredicate() const
Return the ICMP or FCMP predicate value.
Definition: Constants.cpp:1103
ArrayRef< unsigned > getIndices() const
Assert that this is an insertvalue or exactvalue expression and return the list of indices...
Definition: Constants.cpp:1095
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.
Definition: Value.h:87
hexagon gen pred
bool isCompare() const
Return true if this is a compare constant expression.
Definition: Constants.cpp:1064
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
FunctionType * getFunctionType() const
getFunctionType - InlineAsm's are always pointers to functions.
Definition: InlineAsm.cpp:54
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
Definition: DerivedTypes.h:458
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.
Definition: Value.h:230
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.
Definition: Debug.cpp:132
Class to represent vector types.
Definition: DerivedTypes.h:369
ConstantArray - Constant Array Declarations.
Definition: Constants.h:411
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:602
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.
Definition: Hashing.h:480
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.
Definition: Value.h:441
Type * getSourceElementType() const
Definition: Constants.cpp:2277
#define I(x, y, z)
Definition: MD5.cpp:54
ExtractElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to...
ConstantAggrKeyType< ConstantVector > ValType
Compile-time customization of User operands.
Definition: User.h:43
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool classof(const Value *V)
ConstantInfo< ConstantClass >::TypeClass TypeClass
LLVM Value Representation.
Definition: Value.h:71
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
#define DEBUG(X)
Definition: Debug.h:100
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:31
Use & Op()
Definition: User.h:117
bool operator==(const InlineAsm *Asm) const
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:66
SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
bool isAlignStack() const
Definition: InlineAsm.h:69
static bool classof(const ConstantExpr *CE)
static bool classof(const ConstantExpr *CE)
ConstantInfo< ConstantClass >::ValType ValType