LLVM  5.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/Constant.h"
26 #include "llvm/IR/Constants.h"
27 #include "llvm/IR/DerivedTypes.h"
28 #include "llvm/IR/InlineAsm.h"
29 #include "llvm/IR/Instruction.h"
30 #include "llvm/IR/OperandTraits.h"
31 #include "llvm/Support/Casting.h"
32 #include "llvm/Support/Debug.h"
35 #include <cassert>
36 #include <cstddef>
37 #include <cstdint>
38 #include <utility>
39 
40 #define DEBUG_TYPE "ir"
41 
42 namespace llvm {
43 
44 /// UnaryConstantExpr - This class is private to Constants.cpp, and is used
45 /// behind the scenes to implement unary constant exprs.
47 public:
48  UnaryConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
49  : ConstantExpr(Ty, Opcode, &Op<0>(), 1) {
50  Op<0>() = C;
51  }
52 
53  // allocate space for exactly one operand
54  void *operator new(size_t s) {
55  return User::operator new(s, 1);
56  }
57 
59 };
60 
61 /// BinaryConstantExpr - This class is private to Constants.cpp, and is used
62 /// behind the scenes to implement binary constant exprs.
64 public:
65  BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2,
66  unsigned Flags)
67  : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) {
68  Op<0>() = C1;
69  Op<1>() = C2;
71  }
72 
73  // allocate space for exactly two operands
74  void *operator new(size_t s) {
75  return User::operator new(s, 2);
76  }
77 
78  /// Transparently provide more efficient getOperand methods.
80 };
81 
82 /// SelectConstantExpr - This class is private to Constants.cpp, and is used
83 /// behind the scenes to implement select constant exprs.
85 public:
87  : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) {
88  Op<0>() = C1;
89  Op<1>() = C2;
90  Op<2>() = C3;
91  }
92 
93  // allocate space for exactly three operands
94  void *operator new(size_t s) {
95  return User::operator new(s, 3);
96  }
97 
98  /// Transparently provide more efficient getOperand methods.
100 };
101 
102 /// ExtractElementConstantExpr - This class is private to
103 /// Constants.cpp, and is used behind the scenes to implement
104 /// extractelement constant exprs.
106 public:
108  : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
109  Instruction::ExtractElement, &Op<0>(), 2) {
110  Op<0>() = C1;
111  Op<1>() = C2;
112  }
113 
114  // allocate space for exactly two operands
115  void *operator new(size_t s) {
116  return User::operator new(s, 2);
117  }
118 
119  /// Transparently provide more efficient getOperand methods.
121 };
122 
123 /// InsertElementConstantExpr - This class is private to
124 /// Constants.cpp, and is used behind the scenes to implement
125 /// insertelement constant exprs.
127 public:
129  : ConstantExpr(C1->getType(), Instruction::InsertElement,
130  &Op<0>(), 3) {
131  Op<0>() = C1;
132  Op<1>() = C2;
133  Op<2>() = C3;
134  }
135 
136  // allocate space for exactly three operands
137  void *operator new(size_t s) {
138  return User::operator new(s, 3);
139  }
140 
141  /// Transparently provide more efficient getOperand methods.
143 };
144 
145 /// ShuffleVectorConstantExpr - This class is private to
146 /// Constants.cpp, and is used behind the scenes to implement
147 /// shufflevector constant exprs.
149 public:
152  cast<VectorType>(C1->getType())->getElementType(),
153  cast<VectorType>(C3->getType())->getNumElements()),
154  Instruction::ShuffleVector,
155  &Op<0>(), 3) {
156  Op<0>() = C1;
157  Op<1>() = C2;
158  Op<2>() = C3;
159  }
160 
161  // allocate space for exactly three operands
162  void *operator new(size_t s) {
163  return User::operator new(s, 3);
164  }
165 
166  /// Transparently provide more efficient getOperand methods.
168 };
169 
170 /// ExtractValueConstantExpr - This class is private to
171 /// Constants.cpp, and is used behind the scenes to implement
172 /// extractvalue constant exprs.
174 public:
176  Type *DestTy)
177  : ConstantExpr(DestTy, Instruction::ExtractValue, &Op<0>(), 1),
178  Indices(IdxList.begin(), IdxList.end()) {
179  Op<0>() = Agg;
180  }
181 
182  // allocate space for exactly one operand
183  void *operator new(size_t s) {
184  return User::operator new(s, 1);
185  }
186 
187  /// Indices - These identify which value to extract.
189 
190  /// Transparently provide more efficient getOperand methods.
192 
193  static bool classof(const ConstantExpr *CE) {
194  return CE->getOpcode() == Instruction::ExtractValue;
195  }
196  static bool classof(const Value *V) {
197  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
198  }
199 };
200 
201 /// InsertValueConstantExpr - This class is private to
202 /// Constants.cpp, and is used behind the scenes to implement
203 /// insertvalue constant exprs.
205 public:
207  ArrayRef<unsigned> IdxList, Type *DestTy)
208  : ConstantExpr(DestTy, Instruction::InsertValue, &Op<0>(), 2),
209  Indices(IdxList.begin(), IdxList.end()) {
210  Op<0>() = Agg;
211  Op<1>() = Val;
212  }
213 
214  // allocate space for exactly one operand
215  void *operator new(size_t s) {
216  return User::operator new(s, 2);
217  }
218 
219  /// Indices - These identify the position for the insertion.
221 
222  /// Transparently provide more efficient getOperand methods.
224 
225  static bool classof(const ConstantExpr *CE) {
226  return CE->getOpcode() == Instruction::InsertValue;
227  }
228  static bool classof(const Value *V) {
229  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
230  }
231 };
232 
233 /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
234 /// used behind the scenes to implement getelementpr constant exprs.
236  Type *SrcElementTy;
237  Type *ResElementTy;
238 
239  GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C,
240  ArrayRef<Constant *> IdxList, Type *DestTy);
241 
242 public:
243  static GetElementPtrConstantExpr *Create(Type *SrcElementTy, Constant *C,
244  ArrayRef<Constant *> IdxList,
245  Type *DestTy, unsigned Flags) {
246  GetElementPtrConstantExpr *Result = new (IdxList.size() + 1)
247  GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy);
248  Result->SubclassOptionalData = Flags;
249  return Result;
250  }
251 
252  Type *getSourceElementType() const;
253  Type *getResultElementType() const;
254 
255  /// Transparently provide more efficient getOperand methods.
257 
258  static bool classof(const ConstantExpr *CE) {
259  return CE->getOpcode() == Instruction::GetElementPtr;
260  }
261  static bool classof(const Value *V) {
262  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
263  }
264 };
265 
266 // CompareConstantExpr - This class is private to Constants.cpp, and is used
267 // behind the scenes to implement ICmp and FCmp constant expressions. This is
268 // needed in order to store the predicate value for these instructions.
270 public:
271  unsigned short predicate;
273  unsigned short pred, Constant* LHS, Constant* RHS)
274  : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) {
275  Op<0>() = LHS;
276  Op<1>() = RHS;
277  }
278 
279  // allocate space for exactly two operands
280  void *operator new(size_t s) {
281  return User::operator new(s, 2);
282  }
283 
284  /// Transparently provide more efficient getOperand methods.
286 
287  static bool classof(const ConstantExpr *CE) {
288  return CE->getOpcode() == Instruction::ICmp ||
289  CE->getOpcode() == Instruction::FCmp;
290  }
291  static bool classof(const Value *V) {
292  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
293  }
294 };
295 
296 template <>
298  : public FixedNumOperandTraits<UnaryConstantExpr, 1> {};
300 
301 template <>
305 
306 template <>
310 
311 template <>
315 
316 template <>
320 
321 template <>
325 
326 template <>
330 
331 template <>
335 
336 template <>
339 
341 
342 template <>
346 
347 template <class ConstantClass> struct ConstantAggrKeyType;
348 struct InlineAsmKeyType;
349 struct ConstantExprKeyType;
350 
351 template <class ConstantClass> struct ConstantInfo;
352 template <> struct ConstantInfo<ConstantExpr> {
353  using ValType = ConstantExprKeyType;
354  using TypeClass = Type;
355 };
356 template <> struct ConstantInfo<InlineAsm> {
359 };
360 template <> struct ConstantInfo<ConstantArray> {
363 };
364 template <> struct ConstantInfo<ConstantStruct> {
367 };
368 template <> struct ConstantInfo<ConstantVector> {
371 };
372 
373 template <class ConstantClass> struct ConstantAggrKeyType {
375 
377 
379  : Operands(Operands) {}
380 
381  ConstantAggrKeyType(const ConstantClass *C,
382  SmallVectorImpl<Constant *> &Storage) {
383  assert(Storage.empty() && "Expected empty storage");
384  for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
385  Storage.push_back(C->getOperand(I));
386  Operands = Storage;
387  }
388 
389  bool operator==(const ConstantAggrKeyType &X) const {
390  return Operands == X.Operands;
391  }
392 
393  bool operator==(const ConstantClass *C) const {
394  if (Operands.size() != C->getNumOperands())
395  return false;
396  for (unsigned I = 0, E = Operands.size(); I != E; ++I)
397  if (Operands[I] != C->getOperand(I))
398  return false;
399  return true;
400  }
401 
402  unsigned getHash() const {
403  return hash_combine_range(Operands.begin(), Operands.end());
404  }
405 
407 
408  ConstantClass *create(TypeClass *Ty) const {
409  return new (Operands.size()) ConstantClass(Ty, Operands);
410  }
411 };
412 
420 
424  : AsmString(AsmString), Constraints(Constraints), FTy(FTy),
425  HasSideEffects(HasSideEffects), IsAlignStack(IsAlignStack),
426  AsmDialect(AsmDialect) {}
427 
429  : AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()),
430  FTy(Asm->getFunctionType()), HasSideEffects(Asm->hasSideEffects()),
431  IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()) {}
432 
433  bool operator==(const InlineAsmKeyType &X) const {
434  return HasSideEffects == X.HasSideEffects &&
437  FTy == X.FTy;
438  }
439 
440  bool operator==(const InlineAsm *Asm) const {
441  return HasSideEffects == Asm->hasSideEffects() &&
442  IsAlignStack == Asm->isAlignStack() &&
443  AsmDialect == Asm->getDialect() &&
444  AsmString == Asm->getAsmString() &&
445  Constraints == Asm->getConstraintString() &&
446  FTy == Asm->getFunctionType();
447  }
448 
449  unsigned getHash() const {
451  AsmDialect, FTy);
452  }
453 
455 
456  InlineAsm *create(TypeClass *Ty) const {
460  }
461 };
462 
464  uint8_t Opcode;
466  uint16_t SubclassData;
470 
472  unsigned short SubclassData = 0,
473  unsigned short SubclassOptionalData = 0,
475  Type *ExplicitTy = nullptr)
476  : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData),
479 
481  : Opcode(CE->getOpcode()),
482  SubclassOptionalData(CE->getRawSubclassOptionalData()),
483  SubclassData(CE->isCompare() ? CE->getPredicate() : 0), Ops(Operands),
484  Indexes(CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()) {}
485 
488  : Opcode(CE->getOpcode()),
489  SubclassOptionalData(CE->getRawSubclassOptionalData()),
490  SubclassData(CE->isCompare() ? CE->getPredicate() : 0),
491  Indexes(CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()) {
492  assert(Storage.empty() && "Expected empty storage");
493  for (unsigned I = 0, E = CE->getNumOperands(); I != E; ++I)
494  Storage.push_back(CE->getOperand(I));
495  Ops = Storage;
496  }
497 
498  bool operator==(const ConstantExprKeyType &X) const {
499  return Opcode == X.Opcode && SubclassData == X.SubclassData &&
501  Indexes == X.Indexes;
502  }
503 
504  bool operator==(const ConstantExpr *CE) const {
505  if (Opcode != CE->getOpcode())
506  return false;
508  return false;
509  if (Ops.size() != CE->getNumOperands())
510  return false;
511  if (SubclassData != (CE->isCompare() ? CE->getPredicate() : 0))
512  return false;
513  for (unsigned I = 0, E = Ops.size(); I != E; ++I)
514  if (Ops[I] != CE->getOperand(I))
515  return false;
516  if (Indexes != (CE->hasIndices() ? CE->getIndices() : ArrayRef<unsigned>()))
517  return false;
518  return true;
519  }
520 
521  unsigned getHash() const {
523  hash_combine_range(Ops.begin(), Ops.end()),
525  }
526 
528 
530  switch (Opcode) {
531  default:
533  return new UnaryConstantExpr(Opcode, Ops[0], Ty);
534  if ((Opcode >= Instruction::BinaryOpsBegin &&
535  Opcode < Instruction::BinaryOpsEnd))
536  return new BinaryConstantExpr(Opcode, Ops[0], Ops[1],
538  llvm_unreachable("Invalid ConstantExpr!");
539  case Instruction::Select:
540  return new SelectConstantExpr(Ops[0], Ops[1], Ops[2]);
541  case Instruction::ExtractElement:
542  return new ExtractElementConstantExpr(Ops[0], Ops[1]);
543  case Instruction::InsertElement:
544  return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]);
545  case Instruction::ShuffleVector:
546  return new ShuffleVectorConstantExpr(Ops[0], Ops[1], Ops[2]);
547  case Instruction::InsertValue:
548  return new InsertValueConstantExpr(Ops[0], Ops[1], Indexes, Ty);
549  case Instruction::ExtractValue:
550  return new ExtractValueConstantExpr(Ops[0], Indexes, Ty);
551  case Instruction::GetElementPtr:
554  : cast<PointerType>(Ops[0]->getType()->getScalarType())
555  ->getElementType(),
556  Ops[0], Ops.slice(1), Ty, SubclassOptionalData);
557  case Instruction::ICmp:
558  return new CompareConstantExpr(Ty, Instruction::ICmp, SubclassData,
559  Ops[0], Ops[1]);
560  case Instruction::FCmp:
561  return new CompareConstantExpr(Ty, Instruction::FCmp, SubclassData,
562  Ops[0], Ops[1]);
563  }
564  }
565 };
566 
567 template <class ConstantClass> class ConstantUniqueMap {
568 public:
571  using LookupKey = std::pair<TypeClass *, ValType>;
572 
573  /// Key and hash together, so that we compute the hash only once and reuse it.
574  using LookupKeyHashed = std::pair<unsigned, LookupKey>;
575 
576 private:
577  struct MapInfo {
578  using ConstantClassInfo = DenseMapInfo<ConstantClass *>;
579 
580  static inline ConstantClass *getEmptyKey() {
581  return ConstantClassInfo::getEmptyKey();
582  }
583 
584  static inline ConstantClass *getTombstoneKey() {
585  return ConstantClassInfo::getTombstoneKey();
586  }
587 
588  static unsigned getHashValue(const ConstantClass *CP) {
590  return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage)));
591  }
592 
593  static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
594  return LHS == RHS;
595  }
596 
597  static unsigned getHashValue(const LookupKey &Val) {
598  return hash_combine(Val.first, Val.second.getHash());
599  }
600 
601  static unsigned getHashValue(const LookupKeyHashed &Val) {
602  return Val.first;
603  }
604 
605  static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
606  if (RHS == getEmptyKey() || RHS == getTombstoneKey())
607  return false;
608  if (LHS.first != RHS->getType())
609  return false;
610  return LHS.second == RHS;
611  }
612 
613  static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) {
614  return isEqual(LHS.second, RHS);
615  }
616  };
617 
618 public:
620 
621 private:
622  MapTy Map;
623 
624 public:
625  typename MapTy::iterator begin() { return Map.begin(); }
626  typename MapTy::iterator end() { return Map.end(); }
627 
628  void freeConstants() {
629  for (auto &I : Map)
630  delete I; // Asserts that use_empty().
631  }
632 
633 private:
634  ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) {
635  ConstantClass *Result = V.create(Ty);
636 
637  assert(Result->getType() == Ty && "Type specified is not correct!");
638  Map.insert_as(Result, HashKey);
639 
640  return Result;
641  }
642 
643 public:
644  /// Return the specified constant from the map, creating it if necessary.
645  ConstantClass *getOrCreate(TypeClass *Ty, ValType V) {
646  LookupKey Key(Ty, V);
647  /// Hash once, and reuse it for the lookup and the insertion if needed.
648  LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
649 
650  ConstantClass *Result = nullptr;
651 
652  auto I = Map.find_as(Lookup);
653  if (I == Map.end())
654  Result = create(Ty, V, Lookup);
655  else
656  Result = *I;
657  assert(Result && "Unexpected nullptr");
658 
659  return Result;
660  }
661 
662  /// Remove this constant from the map
663  void remove(ConstantClass *CP) {
664  typename MapTy::iterator I = Map.find(CP);
665  assert(I != Map.end() && "Constant not found in constant table!");
666  assert(*I == CP && "Didn't find correct element?");
667  Map.erase(I);
668  }
669 
671  ConstantClass *CP, Value *From,
672  Constant *To, unsigned NumUpdated = 0,
673  unsigned OperandNo = ~0u) {
674  LookupKey Key(CP->getType(), ValType(Operands, CP));
675  /// Hash once, and reuse it for the lookup and the insertion if needed.
676  LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
677 
678  auto I = Map.find_as(Lookup);
679  if (I != Map.end())
680  return *I;
681 
682  // Update to the new value. Optimize for the case when we have a single
683  // operand that we're changing, but handle bulk updates efficiently.
684  remove(CP);
685  if (NumUpdated == 1) {
686  assert(OperandNo < CP->getNumOperands() && "Invalid index");
687  assert(CP->getOperand(OperandNo) != To && "I didn't contain From!");
688  CP->setOperand(OperandNo, To);
689  } else {
690  for (unsigned I = 0, E = CP->getNumOperands(); I != E; ++I)
691  if (CP->getOperand(I) == From)
692  CP->setOperand(I, To);
693  }
694  Map.insert_as(CP, Lookup);
695  return nullptr;
696  }
697 
698  void dump() const { DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n"); }
699 };
700 
701 } // end namespace llvm
702 
703 #endif // LLVM_LIB_IR_CONSTANTSCONTEXT_H
InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:243
AsmDialect getDialect() const
Definition: InlineAsm.h:69
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:234
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
ConstantExprKeyType(unsigned Opcode, ArrayRef< Constant * > Ops, unsigned short SubclassData=0, unsigned short SubclassOptionalData=0, ArrayRef< unsigned > Indexes=None, Type *ExplicitTy=nullptr)
ConstantInfo< InlineAsm >::TypeClass TypeClass
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
static bool classof(const ConstantExpr *CE)
unsigned getNumOperands() const
Definition: User.h:176
ExtractValueConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to i...
iterator end() const
Definition: ArrayRef.h:138
bool operator==(const InlineAsmKeyType &X) const
const std::string & getAsmString() const
Definition: InlineAsm.h:81
typename ConstantInfo< llvm::ConstantExpr >::TypeClass TypeClass
Type * getResultElementType() const
Definition: Constants.cpp:2264
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:95
const std::string & getConstraintString() const
Definition: InlineAsm.h:82
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)
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
Definition: Constants.h:1171
MapTy::iterator begin()
bool isCast() const
Definition: Instruction.h:127
ConstantExprKeyType(const ConstantExpr *CE, SmallVectorImpl< Constant * > &Storage)
Class to represent struct types.
Definition: DerivedTypes.h:201
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:42
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:1711
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Class to represent function types.
Definition: DerivedTypes.h:103
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:862
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)
static bool classof(const ConstantExpr *CE)
Class to represent array types.
Definition: DerivedTypes.h:369
static bool classof(const Value *V)
bool operator==(const ConstantExprKeyType &X) const
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:149
std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type cast(const Y &Val)
Definition: Casting.h:240
Class to represent pointers.
Definition: DerivedTypes.h:467
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:200
bool hasSideEffects() const
Definition: InlineAsm.h:67
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:46
typename ConstantInfo< llvm::ConstantExpr >::ValType ValType
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:1080
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:176
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:137
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
Value * getOperand(unsigned i) const
Definition: User.h:154
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:491
unsigned getPredicate() const
Return the ICMP or FCMP predicate value.
Definition: Constants.cpp:1093
ArrayRef< unsigned > getIndices() const
Assert that this is an insertvalue or exactvalue expression and return the list of indices...
Definition: Constants.cpp:1085
SelectConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3)
InlineAsm::AsmDialect AsmDialect
static wasm::ValType getType(const TargetRegisterClass *RC)
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Definition: Value.h:91
std::pair< unsigned, LookupKey > LookupKeyHashed
Key and hash together, so that we compute the hash only once and reuse it.
hexagon gen pred
bool isCompare() const
Return true if this is a compare constant expression.
Definition: Constants.cpp:1054
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:57
#define E
Definition: LargeTest.cpp:27
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:482
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:245
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:132
Class to represent vector types.
Definition: DerivedTypes.h:393
ConstantArray - Constant Array Declarations.
Definition: Constants.h:405
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.
llvm_unreachable("Unknown RegBank!")
bool operator==(const ConstantClass *C) const
static std::vector< std::string > Flags
Definition: FlagsTest.cpp:8
ConstantAggrKeyType(ArrayRef< Constant * > Operands)
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags)
#define C
Definition: LargeTest.cpp:25
unsigned getRawSubclassOptionalData() const
Return the raw optional flags value contained in this value.
Definition: Value.h:466
Type * getSourceElementType() const
Definition: Constants.cpp:2260
#define I(x, y, z)
Definition: MD5.cpp:58
ExtractElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to...
iterator find(const_arg_type_t< ValueT > V)
Definition: DenseSet.h:165
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)
LLVM Value Representation.
Definition: Value.h:73
ConstantInfo< ConstantExpr >::TypeClass TypeClass
typename ConstantInfo< ConstantClass >::TypeClass TypeClass
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
#define DEBUG(X)
Definition: Debug.h:118
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
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:118
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:69
std::pair< TypeClass *, ValType > LookupKey
SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
bool isAlignStack() const
Definition: InlineAsm.h:68
static bool classof(const ConstantExpr *CE)
static bool classof(const ConstantExpr *CE)