LLVM  3.7.0
ConstantsContext.h
Go to the documentation of this file.
1 //===-- ConstantsContext.h - Constants-related Context Interals -----------===//
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/DenseMap.h"
19 #include "llvm/ADT/Hashing.h"
20 #include "llvm/IR/InlineAsm.h"
21 #include "llvm/IR/Instructions.h"
22 #include "llvm/IR/Operator.h"
23 #include "llvm/Support/Debug.h"
26 #include <map>
27 #include <tuple>
28 
29 #define DEBUG_TYPE "ir"
30 
31 namespace llvm {
32 
33 /// UnaryConstantExpr - This class is private to Constants.cpp, and is used
34 /// behind the scenes to implement unary constant exprs.
36  void anchor() override;
37  void *operator new(size_t, unsigned) = delete;
38 public:
39  // allocate space for exactly one operand
40  void *operator new(size_t s) {
41  return User::operator new(s, 1);
42  }
43  UnaryConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
44  : ConstantExpr(Ty, Opcode, &Op<0>(), 1) {
45  Op<0>() = C;
46  }
48 };
49 
50 /// BinaryConstantExpr - This class is private to Constants.cpp, and is used
51 /// behind the scenes to implement binary constant exprs.
53  void anchor() override;
54  void *operator new(size_t, unsigned) = delete;
55 public:
56  // allocate space for exactly two operands
57  void *operator new(size_t s) {
58  return User::operator new(s, 2);
59  }
60  BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2,
61  unsigned Flags)
62  : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) {
63  Op<0>() = C1;
64  Op<1>() = C2;
66  }
67  /// Transparently provide more efficient getOperand methods.
69 };
70 
71 /// SelectConstantExpr - This class is private to Constants.cpp, and is used
72 /// behind the scenes to implement select constant exprs.
74  void anchor() override;
75  void *operator new(size_t, unsigned) = delete;
76 public:
77  // allocate space for exactly three operands
78  void *operator new(size_t s) {
79  return User::operator new(s, 3);
80  }
82  : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) {
83  Op<0>() = C1;
84  Op<1>() = C2;
85  Op<2>() = C3;
86  }
87  /// Transparently provide more efficient getOperand methods.
89 };
90 
91 /// ExtractElementConstantExpr - This class is private to
92 /// Constants.cpp, and is used behind the scenes to implement
93 /// extractelement constant exprs.
95  void anchor() override;
96  void *operator new(size_t, unsigned) = delete;
97 public:
98  // allocate space for exactly two operands
99  void *operator new(size_t s) {
100  return User::operator new(s, 2);
101  }
103  : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
104  Instruction::ExtractElement, &Op<0>(), 2) {
105  Op<0>() = C1;
106  Op<1>() = C2;
107  }
108  /// Transparently provide more efficient getOperand methods.
110 };
111 
112 /// InsertElementConstantExpr - This class is private to
113 /// Constants.cpp, and is used behind the scenes to implement
114 /// insertelement constant exprs.
116  void anchor() override;
117  void *operator new(size_t, unsigned) = delete;
118 public:
119  // allocate space for exactly three operands
120  void *operator new(size_t s) {
121  return User::operator new(s, 3);
122  }
124  : ConstantExpr(C1->getType(), Instruction::InsertElement,
125  &Op<0>(), 3) {
126  Op<0>() = C1;
127  Op<1>() = C2;
128  Op<2>() = C3;
129  }
130  /// Transparently provide more efficient getOperand methods.
132 };
133 
134 /// ShuffleVectorConstantExpr - This class is private to
135 /// Constants.cpp, and is used behind the scenes to implement
136 /// shufflevector constant exprs.
138  void anchor() override;
139  void *operator new(size_t, unsigned) = delete;
140 public:
141  // allocate space for exactly three operands
142  void *operator new(size_t s) {
143  return User::operator new(s, 3);
144  }
147  cast<VectorType>(C1->getType())->getElementType(),
148  cast<VectorType>(C3->getType())->getNumElements()),
149  Instruction::ShuffleVector,
150  &Op<0>(), 3) {
151  Op<0>() = C1;
152  Op<1>() = C2;
153  Op<2>() = C3;
154  }
155  /// Transparently provide more efficient getOperand methods.
157 };
158 
159 /// ExtractValueConstantExpr - This class is private to
160 /// Constants.cpp, and is used behind the scenes to implement
161 /// extractvalue constant exprs.
163  void anchor() override;
164  void *operator new(size_t, unsigned) = delete;
165 public:
166  // allocate space for exactly one operand
167  void *operator new(size_t s) {
168  return User::operator new(s, 1);
169  }
171  Type *DestTy)
172  : ConstantExpr(DestTy, Instruction::ExtractValue, &Op<0>(), 1),
173  Indices(IdxList.begin(), IdxList.end()) {
174  Op<0>() = Agg;
175  }
176 
177  /// Indices - These identify which value to extract.
179 
180  /// Transparently provide more efficient getOperand methods.
182 };
183 
184 /// InsertValueConstantExpr - This class is private to
185 /// Constants.cpp, and is used behind the scenes to implement
186 /// insertvalue constant exprs.
188  void anchor() override;
189  void *operator new(size_t, unsigned) = delete;
190 public:
191  // allocate space for exactly one operand
192  void *operator new(size_t s) {
193  return User::operator new(s, 2);
194  }
196  ArrayRef<unsigned> IdxList, Type *DestTy)
197  : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2),
198  Indices(IdxList.begin(), IdxList.end()) {
199  Op<0>() = Agg;
200  Op<1>() = Val;
201  }
202 
203  /// Indices - These identify the position for the insertion.
205 
206  /// Transparently provide more efficient getOperand methods.
208 };
209 
210 /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
211 /// used behind the scenes to implement getelementpr constant exprs.
213  Type *SrcElementTy;
214  void anchor() override;
215  GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C,
216  ArrayRef<Constant *> IdxList, Type *DestTy);
217 
218 public:
220  ArrayRef<Constant*> IdxList,
221  Type *DestTy,
222  unsigned Flags) {
223  return Create(
224  cast<PointerType>(C->getType()->getScalarType())->getElementType(), C,
225  IdxList, DestTy, Flags);
226  }
227  static GetElementPtrConstantExpr *Create(Type *SrcElementTy, Constant *C,
228  ArrayRef<Constant *> IdxList,
229  Type *DestTy, unsigned Flags) {
230  GetElementPtrConstantExpr *Result = new (IdxList.size() + 1)
231  GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy);
232  Result->SubclassOptionalData = Flags;
233  return Result;
234  }
235  Type *getSourceElementType() const;
236  /// Transparently provide more efficient getOperand methods.
238 };
239 
240 // CompareConstantExpr - This class is private to Constants.cpp, and is used
241 // behind the scenes to implement ICmp and FCmp constant expressions. This is
242 // needed in order to store the predicate value for these instructions.
244  void anchor() override;
245  void *operator new(size_t, unsigned) = delete;
246 public:
247  // allocate space for exactly two operands
248  void *operator new(size_t s) {
249  return User::operator new(s, 2);
250  }
251  unsigned short predicate;
253  unsigned short pred, Constant* LHS, Constant* RHS)
254  : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) {
255  Op<0>() = LHS;
256  Op<1>() = RHS;
257  }
258  /// Transparently provide more efficient getOperand methods.
260 };
261 
262 template <>
264  : public FixedNumOperandTraits<UnaryConstantExpr, 1> {};
266 
267 template <>
271 
272 template <>
276 
277 template <>
281 
282 template <>
286 
287 template <>
291 
292 template <>
296 
297 template <>
301 
302 template <>
305 
307 
308 template <>
312 
313 template <class ConstantClass> struct ConstantAggrKeyType;
314 struct InlineAsmKeyType;
315 struct ConstantExprKeyType;
316 
317 template <class ConstantClass> struct ConstantInfo;
318 template <> struct ConstantInfo<ConstantExpr> {
319  typedef ConstantExprKeyType ValType;
320  typedef Type TypeClass;
321 };
322 template <> struct ConstantInfo<InlineAsm> {
325 };
326 template <> struct ConstantInfo<ConstantArray> {
329 };
330 template <> struct ConstantInfo<ConstantStruct> {
333 };
334 template <> struct ConstantInfo<ConstantVector> {
337 };
338 
339 template <class ConstantClass> struct ConstantAggrKeyType {
343  : Operands(Operands) {}
344  ConstantAggrKeyType(const ConstantClass *C,
345  SmallVectorImpl<Constant *> &Storage) {
346  assert(Storage.empty() && "Expected empty storage");
347  for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
348  Storage.push_back(C->getOperand(I));
349  Operands = Storage;
350  }
351 
352  bool operator==(const ConstantAggrKeyType &X) const {
353  return Operands == X.Operands;
354  }
355  bool operator==(const ConstantClass *C) const {
356  if (Operands.size() != C->getNumOperands())
357  return false;
358  for (unsigned I = 0, E = Operands.size(); I != E; ++I)
359  if (Operands[I] != C->getOperand(I))
360  return false;
361  return true;
362  }
363  unsigned getHash() const {
364  return hash_combine_range(Operands.begin(), Operands.end());
365  }
366 
368  ConstantClass *create(TypeClass *Ty) const {
369  return new (Operands.size()) ConstantClass(Ty, Operands);
370  }
371 };
372 
379 
381  bool HasSideEffects, bool IsAlignStack,
383  : AsmString(AsmString), Constraints(Constraints),
384  HasSideEffects(HasSideEffects), IsAlignStack(IsAlignStack),
385  AsmDialect(AsmDialect) {}
387  : AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()),
388  HasSideEffects(Asm->hasSideEffects()),
389  IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()) {}
390 
391  bool operator==(const InlineAsmKeyType &X) const {
392  return HasSideEffects == X.HasSideEffects &&
395  }
396  bool operator==(const InlineAsm *Asm) const {
397  return HasSideEffects == Asm->hasSideEffects() &&
398  IsAlignStack == Asm->isAlignStack() &&
399  AsmDialect == Asm->getDialect() &&
400  AsmString == Asm->getAsmString() &&
402  }
403  unsigned getHash() const {
405  AsmDialect);
406  }
407 
409  InlineAsm *create(TypeClass *Ty) const {
412  }
413 };
414 
416  uint8_t Opcode;
418  uint16_t SubclassData;
422 
424  unsigned short SubclassData = 0,
425  unsigned short SubclassOptionalData = 0,
427  Type *ExplicitTy = nullptr)
428  : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData),
432  : Opcode(CE->getOpcode()),
433  SubclassOptionalData(CE->getRawSubclassOptionalData()),
434  SubclassData(CE->isCompare() ? CE->getPredicate() : 0), Ops(Operands),
435  Indexes(CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()) {}
438  : Opcode(CE->getOpcode()),
439  SubclassOptionalData(CE->getRawSubclassOptionalData()),
440  SubclassData(CE->isCompare() ? CE->getPredicate() : 0),
441  Indexes(CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()) {
442  assert(Storage.empty() && "Expected empty storage");
443  for (unsigned I = 0, E = CE->getNumOperands(); I != E; ++I)
444  Storage.push_back(CE->getOperand(I));
445  Ops = Storage;
446  }
447 
448  bool operator==(const ConstantExprKeyType &X) const {
449  return Opcode == X.Opcode && SubclassData == X.SubclassData &&
451  Indexes == X.Indexes;
452  }
453 
454  bool operator==(const ConstantExpr *CE) const {
455  if (Opcode != CE->getOpcode())
456  return false;
458  return false;
459  if (Ops.size() != CE->getNumOperands())
460  return false;
461  if (SubclassData != (CE->isCompare() ? CE->getPredicate() : 0))
462  return false;
463  for (unsigned I = 0, E = Ops.size(); I != E; ++I)
464  if (Ops[I] != CE->getOperand(I))
465  return false;
466  if (Indexes != (CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()))
467  return false;
468  return true;
469  }
470 
471  unsigned getHash() const {
473  hash_combine_range(Ops.begin(), Ops.end()),
475  }
476 
479  switch (Opcode) {
480  default:
482  return new UnaryConstantExpr(Opcode, Ops[0], Ty);
483  if ((Opcode >= Instruction::BinaryOpsBegin &&
484  Opcode < Instruction::BinaryOpsEnd))
485  return new BinaryConstantExpr(Opcode, Ops[0], Ops[1],
487  llvm_unreachable("Invalid ConstantExpr!");
488  case Instruction::Select:
489  return new SelectConstantExpr(Ops[0], Ops[1], Ops[2]);
491  return new ExtractElementConstantExpr(Ops[0], Ops[1]);
492  case Instruction::InsertElement:
493  return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]);
494  case Instruction::ShuffleVector:
495  return new ShuffleVectorConstantExpr(Ops[0], Ops[1], Ops[2]);
496  case Instruction::InsertValue:
497  return new InsertValueConstantExpr(Ops[0], Ops[1], Indexes, Ty);
498  case Instruction::ExtractValue:
499  return new ExtractValueConstantExpr(Ops[0], Indexes, Ty);
500  case Instruction::GetElementPtr:
503  : cast<PointerType>(Ops[0]->getType()->getScalarType())
504  ->getElementType(),
505  Ops[0], Ops.slice(1), Ty, SubclassOptionalData);
506  case Instruction::ICmp:
507  return new CompareConstantExpr(Ty, Instruction::ICmp, SubclassData,
508  Ops[0], Ops[1]);
509  case Instruction::FCmp:
510  return new CompareConstantExpr(Ty, Instruction::FCmp, SubclassData,
511  Ops[0], Ops[1]);
512  }
513  }
514 };
515 
516 template <class ConstantClass> class ConstantUniqueMap {
517 public:
520  typedef std::pair<TypeClass *, ValType> LookupKey;
521 
522 private:
523  struct MapInfo {
524  typedef DenseMapInfo<ConstantClass *> ConstantClassInfo;
525  static inline ConstantClass *getEmptyKey() {
526  return ConstantClassInfo::getEmptyKey();
527  }
528  static inline ConstantClass *getTombstoneKey() {
529  return ConstantClassInfo::getTombstoneKey();
530  }
531  static unsigned getHashValue(const ConstantClass *CP) {
533  return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage)));
534  }
535  static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
536  return LHS == RHS;
537  }
538  static unsigned getHashValue(const LookupKey &Val) {
539  return hash_combine(Val.first, Val.second.getHash());
540  }
541  static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
542  if (RHS == getEmptyKey() || RHS == getTombstoneKey())
543  return false;
544  if (LHS.first != RHS->getType())
545  return false;
546  return LHS.second == RHS;
547  }
548  };
549 
550 public:
552 
553 private:
554  MapTy Map;
555 
556 public:
557  typename MapTy::iterator map_begin() { return Map.begin(); }
558  typename MapTy::iterator map_end() { return Map.end(); }
559 
560  void freeConstants() {
561  for (auto &I : Map)
562  // Asserts that use_empty().
563  delete I.first;
564  }
565 
566 private:
567  ConstantClass *create(TypeClass *Ty, ValType V) {
568  ConstantClass *Result = V.create(Ty);
569 
570  assert(Result->getType() == Ty && "Type specified is not correct!");
571  insert(Result);
572 
573  return Result;
574  }
575 
576 public:
577  /// Return the specified constant from the map, creating it if necessary.
578  ConstantClass *getOrCreate(TypeClass *Ty, ValType V) {
579  LookupKey Lookup(Ty, V);
580  ConstantClass *Result = nullptr;
581 
582  auto I = find(Lookup);
583  if (I == Map.end())
584  Result = create(Ty, V);
585  else
586  Result = I->first;
587  assert(Result && "Unexpected nullptr");
588 
589  return Result;
590  }
591 
592  /// Find the constant by lookup key.
594  return Map.find_as(Lookup);
595  }
596 
597  /// Insert the constant into its proper slot.
598  void insert(ConstantClass *CP) { Map[CP] = '\0'; }
599 
600  /// Remove this constant from the map
601  void remove(ConstantClass *CP) {
602  typename MapTy::iterator I = Map.find(CP);
603  assert(I != Map.end() && "Constant not found in constant table!");
604  assert(I->first == CP && "Didn't find correct element?");
605  Map.erase(I);
606  }
607 
609  ConstantClass *CP, Value *From,
610  Constant *To, unsigned NumUpdated = 0,
611  unsigned OperandNo = ~0u) {
612  LookupKey Lookup(CP->getType(), ValType(Operands, CP));
613  auto I = find(Lookup);
614  if (I != Map.end())
615  return I->first;
616 
617  // Update to the new value. Optimize for the case when we have a single
618  // operand that we're changing, but handle bulk updates efficiently.
619  remove(CP);
620  if (NumUpdated == 1) {
621  assert(OperandNo < CP->getNumOperands() && "Invalid index");
622  assert(CP->getOperand(OperandNo) != To && "I didn't contain From!");
623  CP->setOperand(OperandNo, To);
624  } else {
625  for (unsigned I = 0, E = CP->getNumOperands(); I != E; ++I)
626  if (CP->getOperand(I) == From)
627  CP->setOperand(I, To);
628  }
629  insert(CP);
630  return nullptr;
631  }
632 
633  void dump() const { DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n"); }
634 };
635 
636 } // end namespace llvm
637 
638 #endif
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:240
AsmDialect getDialect() const
Definition: InlineAsm.h:70
ConstantInfo< InlineAsm >::TypeClass TypeClass
void insert(ConstantClass *CP)
Insert the constant into its proper slot.
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.
unsigned getNumOperands() const
Definition: User.h:138
ExtractValueConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to i...
iterator end() const
Definition: ArrayRef.h:123
bool operator==(const InlineAsmKeyType &X) const
const std::string & getAsmString() const
Definition: InlineAsm.h:82
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.
const_iterator begin(StringRef path)
Get begin iterator over path.
Definition: Path.cpp:232
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.
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Definition: Function.cpp:822
unsigned getOpcode() const
getOpcode - Return the opcode at the root of this constant expression
Definition: Constants.h:1144
ConstantInfo< ConstantClass >::TypeClass TypeClass
bool isCast() const
Definition: Instruction.h:118
ConstantExprKeyType(const ConstantExpr *CE, SmallVectorImpl< Constant * > &Storage)
StructType - Class to represent struct types.
Definition: DerivedTypes.h:191
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APInt.h:33
CompareConstantExpr(Type *ty, Instruction::OtherOps opc, unsigned short pred, Constant *LHS, Constant *RHS)
static ConstantInt * ExtractElement(Constant *V, Constant *Idx)
MapTy::iterator find(LookupKey Lookup)
Find the constant by lookup key.
ExtractValueConstantExpr(Constant *Agg, ArrayRef< unsigned > IdxList, Type *DestTy)
InlineAsmKeyType(StringRef AsmString, StringRef Constraints, bool HasSideEffects, bool IsAlignStack, InlineAsm::AsmDialect AsmDialect)
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:1868
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
ConstantExpr - a constant value that is initialized with an expression using other constant values...
Definition: Constants.h:852
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
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
Definition: SmallVector.h:57
std::pair< TypeClass *, ValType > LookupKey
ArrayType - Class to represent array types.
Definition: DerivedTypes.h:336
bool operator==(const ConstantExprKeyType &X) const
MapTy::iterator map_begin()
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:134
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Definition: Casting.h:222
PointerType - Class to represent pointers.
Definition: DerivedTypes.h:449
unsigned getHash() const
UnaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implemen...
static GetElementPtrConstantExpr * Create(Constant *C, ArrayRef< Constant * > IdxList, Type *DestTy, unsigned Flags)
bool erase(const KeyT &Val)
Definition: DenseMap.h:206
InsertValueConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to im...
ConstantAggrKeyType(const ConstantClass *C, SmallVectorImpl< Constant * > &Storage)
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:41
bool hasIndices() const
Return true if this is an insertvalue or extractvalue expression, and the getIndices() method may be ...
Definition: Constants.cpp:1210
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
ArrayRef< unsigned > Indexes
static int Lookup(const TableEntry *Table, unsigned N, unsigned Opcode)
bool operator==(const ConstantExpr *CE) const
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
iterator begin() const
Definition: ArrayRef.h:122
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
Value * getOperand(unsigned i) const
Definition: User.h:118
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant * > Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
SI Fold Operands
InsertElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
ConstantVector - Constant Vector Declarations.
Definition: Constants.h:461
unsigned getPredicate() const
getPredicate - Return the ICMP or FCMP predicate value.
Definition: Constants.cpp:1223
ArrayRef< unsigned > getIndices() const
getIndices - Assert that this is an insertvalue or exactvalue expression and return the list of indic...
Definition: Constants.cpp:1215
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
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Definition: Value.h:84
hexagon gen pred
bool isCompare() const
Return true if this is a compare constant expression.
Definition: Constants.cpp:1181
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
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:222
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.
Definition: Debug.cpp:123
VectorType - Class to represent vector types.
Definition: DerivedTypes.h:362
ConstantArray - Constant Array Declarations.
Definition: Constants.h:356
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:603
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:481
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
const Type * getScalarType() const LLVM_READONLY
getScalarType - If this is a vector type, return the element type, otherwise return 'this'...
Definition: Type.cpp:51
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)
iterator begin()
Definition: DenseMap.h:64
unsigned getRawSubclassOptionalData() const
Return the raw optional flags value contained in this value.
Definition: Value.h:369
Type * getSourceElementType() const
Definition: Constants.cpp:2410
#define I(x, y, z)
Definition: MD5.cpp:54
ExtractElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to...
DenseMap< ConstantClass *, char, MapInfo > MapTy
ConstantAggrKeyType< ConstantVector > ValType
iterator end()
Definition: DenseMap.h:68
iterator find(const KeyT &Val)
Definition: DenseMap.h:124
Compile-time customization of User operands.
Definition: User.h:34
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
iterator find_as(const LookupKeyT &Val)
Alternate version of find() which allows a different, and possibly less expensive, key type.
Definition: DenseMap.h:143
ConstantInfo< ConstantClass >::TypeClass TypeClass
LLVM Value Representation.
Definition: Value.h:69
MapTy::iterator map_end()
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
#define DEBUG(X)
Definition: Debug.h:92
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
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:93
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
ConstantInfo< ConstantClass >::ValType ValType