LLVM  16.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/DenseMapInfo.h"
19 #include "llvm/ADT/DenseSet.h"
20 #include "llvm/ADT/Hashing.h"
21 #include "llvm/ADT/None.h"
22 #include "llvm/ADT/SmallVector.h"
23 #include "llvm/ADT/StringRef.h"
24 #include "llvm/IR/Constant.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/Instructions.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 /// CastConstantExpr - This class is private to Constants.cpp, and is used
45 /// behind the scenes to implement cast constant exprs.
46 class CastConstantExpr final : public ConstantExpr {
47 public:
48  CastConstantExpr(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) { return User::operator new(S, 1); }
55  void operator delete(void *Ptr) { User::operator delete(Ptr); }
56 
58 
59  static bool classof(const ConstantExpr *CE) {
60  return Instruction::isCast(CE->getOpcode());
61  }
62  static bool classof(const Value *V) {
63  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
64  }
65 };
66 
67 /// BinaryConstantExpr - This class is private to Constants.cpp, and is used
68 /// behind the scenes to implement binary constant exprs.
69 class BinaryConstantExpr final : public ConstantExpr {
70 public:
71  BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2,
72  unsigned Flags)
73  : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) {
74  Op<0>() = C1;
75  Op<1>() = C2;
76  SubclassOptionalData = Flags;
77  }
78 
79  // allocate space for exactly two operands
80  void *operator new(size_t S) { return User::operator new(S, 2); }
81  void operator delete(void *Ptr) { User::operator delete(Ptr); }
82 
83  /// Transparently provide more efficient getOperand methods.
85 
86  static bool classof(const ConstantExpr *CE) {
87  return Instruction::isBinaryOp(CE->getOpcode());
88  }
89  static bool classof(const Value *V) {
90  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
91  }
92 };
93 
94 /// SelectConstantExpr - This class is private to Constants.cpp, and is used
95 /// behind the scenes to implement select constant exprs.
96 class SelectConstantExpr final : public ConstantExpr {
97 public:
99  : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) {
100  Op<0>() = C1;
101  Op<1>() = C2;
102  Op<2>() = C3;
103  }
104 
105  // allocate space for exactly three operands
106  void *operator new(size_t S) { return User::operator new(S, 3); }
107  void operator delete(void *Ptr) { User::operator delete(Ptr); }
108 
109  /// Transparently provide more efficient getOperand methods.
111 
112  static bool classof(const ConstantExpr *CE) {
113  return CE->getOpcode() == Instruction::Select;
114  }
115  static bool classof(const Value *V) {
116  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
117  }
118 };
119 
120 /// ExtractElementConstantExpr - This class is private to
121 /// Constants.cpp, and is used behind the scenes to implement
122 /// extractelement constant exprs.
124 public:
126  : ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
127  Instruction::ExtractElement, &Op<0>(), 2) {
128  Op<0>() = C1;
129  Op<1>() = C2;
130  }
131 
132  // allocate space for exactly two operands
133  void *operator new(size_t S) { return User::operator new(S, 2); }
134  void operator delete(void *Ptr) { User::operator delete(Ptr); }
135 
136  /// Transparently provide more efficient getOperand methods.
138 
139  static bool classof(const ConstantExpr *CE) {
140  return CE->getOpcode() == Instruction::ExtractElement;
141  }
142  static bool classof(const Value *V) {
143  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
144  }
145 };
146 
147 /// InsertElementConstantExpr - This class is private to
148 /// Constants.cpp, and is used behind the scenes to implement
149 /// insertelement constant exprs.
151 public:
153  : ConstantExpr(C1->getType(), Instruction::InsertElement,
154  &Op<0>(), 3) {
155  Op<0>() = C1;
156  Op<1>() = C2;
157  Op<2>() = C3;
158  }
159 
160  // allocate space for exactly three operands
161  void *operator new(size_t S) { return User::operator new(S, 3); }
162  void operator delete(void *Ptr) { User::operator delete(Ptr); }
163 
164  /// Transparently provide more efficient getOperand methods.
166 
167  static bool classof(const ConstantExpr *CE) {
168  return CE->getOpcode() == Instruction::InsertElement;
169  }
170  static bool classof(const Value *V) {
171  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
172  }
173 };
174 
175 /// ShuffleVectorConstantExpr - This class is private to
176 /// Constants.cpp, and is used behind the scenes to implement
177 /// shufflevector constant exprs.
179 public:
182  cast<VectorType>(C1->getType())->getElementType(),
184  Instruction::ShuffleVector, &Op<0>(), 2) {
186  "Invalid shuffle vector instruction operands!");
187  Op<0>() = C1;
188  Op<1>() = C2;
189  ShuffleMask.assign(Mask.begin(), Mask.end());
192  }
193 
196 
197  void *operator new(size_t S) { return User::operator new(S, 2); }
198  void operator delete(void *Ptr) { return User::operator delete(Ptr); }
199 
200  /// Transparently provide more efficient getOperand methods.
202 
203  static bool classof(const ConstantExpr *CE) {
204  return CE->getOpcode() == Instruction::ShuffleVector;
205  }
206  static bool classof(const Value *V) {
207  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
208  }
209 };
210 
211 /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
212 /// used behind the scenes to implement getelementpr constant exprs.
214  Type *SrcElementTy;
215  Type *ResElementTy;
216 
217  GetElementPtrConstantExpr(Type *SrcElementTy, Constant *C,
218  ArrayRef<Constant *> IdxList, Type *DestTy);
219 
220 public:
221  static GetElementPtrConstantExpr *Create(Type *SrcElementTy, Constant *C,
222  ArrayRef<Constant *> IdxList,
223  Type *DestTy, unsigned Flags) {
224  GetElementPtrConstantExpr *Result = new (IdxList.size() + 1)
225  GetElementPtrConstantExpr(SrcElementTy, C, IdxList, DestTy);
226  Result->SubclassOptionalData = Flags;
227  return Result;
228  }
229 
230  Type *getSourceElementType() const;
231  Type *getResultElementType() const;
232 
233  /// Transparently provide more efficient getOperand methods.
235 
236  static bool classof(const ConstantExpr *CE) {
237  return CE->getOpcode() == Instruction::GetElementPtr;
238  }
239  static bool classof(const Value *V) {
240  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
241  }
242 };
243 
244 // CompareConstantExpr - This class is private to Constants.cpp, and is used
245 // behind the scenes to implement ICmp and FCmp constant expressions. This is
246 // needed in order to store the predicate value for these instructions.
247 class CompareConstantExpr final : public ConstantExpr {
248 public:
249  unsigned short predicate;
251  unsigned short pred, Constant* LHS, Constant* RHS)
252  : ConstantExpr(ty, opc, &Op<0>(), 2), predicate(pred) {
253  Op<0>() = LHS;
254  Op<1>() = RHS;
255  }
256 
257  // allocate space for exactly two operands
258  void *operator new(size_t S) { return User::operator new(S, 2); }
259  void operator delete(void *Ptr) { return User::operator delete(Ptr); }
260 
261  /// Transparently provide more efficient getOperand methods.
263 
264  static bool classof(const ConstantExpr *CE) {
265  return CE->getOpcode() == Instruction::ICmp ||
266  CE->getOpcode() == Instruction::FCmp;
267  }
268  static bool classof(const Value *V) {
269  return isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V));
270  }
271 };
272 
273 template <>
275  : public FixedNumOperandTraits<CastConstantExpr, 1> {};
277 
278 template <>
280  : public FixedNumOperandTraits<BinaryConstantExpr, 2> {};
282 
283 template <>
285  : public FixedNumOperandTraits<SelectConstantExpr, 3> {};
287 
288 template <>
290  : public FixedNumOperandTraits<ExtractElementConstantExpr, 2> {};
292 
293 template <>
295  : public FixedNumOperandTraits<InsertElementConstantExpr, 3> {};
297 
298 template <>
300  : public FixedNumOperandTraits<ShuffleVectorConstantExpr, 2> {};
302 
303 template <>
305  : public VariadicOperandTraits<GetElementPtrConstantExpr, 1> {};
306 
308 
309 template <>
311  : public FixedNumOperandTraits<CompareConstantExpr, 2> {};
313 
314 template <class ConstantClass> struct ConstantAggrKeyType;
315 struct InlineAsmKeyType;
316 struct ConstantExprKeyType;
317 
318 template <class ConstantClass> struct ConstantInfo;
319 template <> struct ConstantInfo<ConstantExpr> {
321  using TypeClass = Type;
322 };
323 template <> struct ConstantInfo<InlineAsm> {
326 };
327 template <> struct ConstantInfo<ConstantArray> {
330 };
331 template <> struct ConstantInfo<ConstantStruct> {
334 };
335 template <> struct ConstantInfo<ConstantVector> {
338 };
339 
340 template <class ConstantClass> struct ConstantAggrKeyType {
342 
344 
346  : Operands(Operands) {}
347 
348  ConstantAggrKeyType(const ConstantClass *C,
349  SmallVectorImpl<Constant *> &Storage) {
350  assert(Storage.empty() && "Expected empty storage");
351  for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I)
352  Storage.push_back(C->getOperand(I));
353  Operands = Storage;
354  }
355 
356  bool operator==(const ConstantAggrKeyType &X) const {
357  return Operands == X.Operands;
358  }
359 
360  bool operator==(const ConstantClass *C) const {
361  if (Operands.size() != C->getNumOperands())
362  return false;
363  for (unsigned I = 0, E = Operands.size(); I != E; ++I)
364  if (Operands[I] != C->getOperand(I))
365  return false;
366  return true;
367  }
368 
369  unsigned getHash() const {
370  return hash_combine_range(Operands.begin(), Operands.end());
371  }
372 
374 
375  ConstantClass *create(TypeClass *Ty) const {
376  return new (Operands.size()) ConstantClass(Ty, Operands);
377  }
378 };
379 
387  bool CanThrow;
388 
395 
397  : AsmString(Asm->getAsmString()), Constraints(Asm->getConstraintString()),
398  FTy(Asm->getFunctionType()), HasSideEffects(Asm->hasSideEffects()),
399  IsAlignStack(Asm->isAlignStack()), AsmDialect(Asm->getDialect()),
400  CanThrow(Asm->canThrow()) {}
401 
402  bool operator==(const InlineAsmKeyType &X) const {
403  return HasSideEffects == X.HasSideEffects &&
404  IsAlignStack == X.IsAlignStack && AsmDialect == X.AsmDialect &&
405  AsmString == X.AsmString && Constraints == X.Constraints &&
406  FTy == X.FTy && CanThrow == X.CanThrow;
407  }
408 
409  bool operator==(const InlineAsm *Asm) const {
410  return HasSideEffects == Asm->hasSideEffects() &&
411  IsAlignStack == Asm->isAlignStack() &&
412  AsmDialect == Asm->getDialect() &&
413  AsmString == Asm->getAsmString() &&
414  Constraints == Asm->getConstraintString() &&
415  FTy == Asm->getFunctionType() && CanThrow == Asm->canThrow();
416  }
417 
418  unsigned getHash() const {
421  }
422 
424 
425  InlineAsm *create(TypeClass *Ty) const {
427  return new InlineAsm(FTy, std::string(AsmString), std::string(Constraints),
429  }
430 };
431 
433 private:
434  uint8_t Opcode;
435  uint8_t SubclassOptionalData;
436  uint16_t SubclassData;
438  ArrayRef<int> ShuffleMask;
439  Type *ExplicitTy;
440 
441  static ArrayRef<int> getShuffleMaskIfValid(const ConstantExpr *CE) {
442  if (CE->getOpcode() == Instruction::ShuffleVector)
443  return CE->getShuffleMask();
444  return None;
445  }
446 
447  static Type *getSourceElementTypeIfValid(const ConstantExpr *CE) {
448  if (auto *GEPCE = dyn_cast<GetElementPtrConstantExpr>(CE))
449  return GEPCE->getSourceElementType();
450  return nullptr;
451  }
452 
453 public:
455  unsigned short SubclassData = 0,
456  unsigned short SubclassOptionalData = 0,
457  ArrayRef<int> ShuffleMask = None,
458  Type *ExplicitTy = nullptr)
459  : Opcode(Opcode), SubclassOptionalData(SubclassOptionalData),
460  SubclassData(SubclassData), Ops(Ops), ShuffleMask(ShuffleMask),
461  ExplicitTy(ExplicitTy) {}
462 
464  : Opcode(CE->getOpcode()),
465  SubclassOptionalData(CE->getRawSubclassOptionalData()),
466  SubclassData(CE->isCompare() ? CE->getPredicate() : 0), Ops(Operands),
467  ShuffleMask(getShuffleMaskIfValid(CE)),
468  ExplicitTy(getSourceElementTypeIfValid(CE)) {}
469 
472  : Opcode(CE->getOpcode()),
473  SubclassOptionalData(CE->getRawSubclassOptionalData()),
474  SubclassData(CE->isCompare() ? CE->getPredicate() : 0),
475  ShuffleMask(getShuffleMaskIfValid(CE)),
476  ExplicitTy(getSourceElementTypeIfValid(CE)) {
477  assert(Storage.empty() && "Expected empty storage");
478  for (unsigned I = 0, E = CE->getNumOperands(); I != E; ++I)
479  Storage.push_back(CE->getOperand(I));
480  Ops = Storage;
481  }
482 
483  bool operator==(const ConstantExprKeyType &X) const {
484  return Opcode == X.Opcode && SubclassData == X.SubclassData &&
485  SubclassOptionalData == X.SubclassOptionalData && Ops == X.Ops &&
486  ShuffleMask == X.ShuffleMask && ExplicitTy == X.ExplicitTy;
487  }
488 
489  bool operator==(const ConstantExpr *CE) const {
490  if (Opcode != CE->getOpcode())
491  return false;
492  if (SubclassOptionalData != CE->getRawSubclassOptionalData())
493  return false;
494  if (Ops.size() != CE->getNumOperands())
495  return false;
496  if (SubclassData != (CE->isCompare() ? CE->getPredicate() : 0))
497  return false;
498  for (unsigned I = 0, E = Ops.size(); I != E; ++I)
499  if (Ops[I] != CE->getOperand(I))
500  return false;
501  if (ShuffleMask != getShuffleMaskIfValid(CE))
502  return false;
503  if (ExplicitTy != getSourceElementTypeIfValid(CE))
504  return false;
505  return true;
506  }
507 
508  unsigned getHash() const {
509  return hash_combine(
510  Opcode, SubclassOptionalData, SubclassData,
511  hash_combine_range(Ops.begin(), Ops.end()),
512  hash_combine_range(ShuffleMask.begin(), ShuffleMask.end()), ExplicitTy);
513  }
514 
516 
518  switch (Opcode) {
519  default:
520  if (Instruction::isCast(Opcode))
521  return new CastConstantExpr(Opcode, Ops[0], Ty);
522  if ((Opcode >= Instruction::BinaryOpsBegin &&
523  Opcode < Instruction::BinaryOpsEnd))
524  return new BinaryConstantExpr(Opcode, Ops[0], Ops[1],
525  SubclassOptionalData);
526  llvm_unreachable("Invalid ConstantExpr!");
527  case Instruction::Select:
528  return new SelectConstantExpr(Ops[0], Ops[1], Ops[2]);
529  case Instruction::ExtractElement:
530  return new ExtractElementConstantExpr(Ops[0], Ops[1]);
531  case Instruction::InsertElement:
532  return new InsertElementConstantExpr(Ops[0], Ops[1], Ops[2]);
533  case Instruction::ShuffleVector:
534  return new ShuffleVectorConstantExpr(Ops[0], Ops[1], ShuffleMask);
535  case Instruction::GetElementPtr:
536  return GetElementPtrConstantExpr::Create(ExplicitTy, Ops[0], Ops.slice(1),
537  Ty, SubclassOptionalData);
538  case Instruction::ICmp:
539  return new CompareConstantExpr(Ty, Instruction::ICmp, SubclassData,
540  Ops[0], Ops[1]);
541  case Instruction::FCmp:
542  return new CompareConstantExpr(Ty, Instruction::FCmp, SubclassData,
543  Ops[0], Ops[1]);
544  }
545  }
546 };
547 
548 // Free memory for a given constant. Assumes the constant has already been
549 // removed from all relevant maps.
550 void deleteConstant(Constant *C);
551 
552 template <class ConstantClass> class ConstantUniqueMap {
553 public:
556  using LookupKey = std::pair<TypeClass *, ValType>;
557 
558  /// Key and hash together, so that we compute the hash only once and reuse it.
559  using LookupKeyHashed = std::pair<unsigned, LookupKey>;
560 
561 private:
562  struct MapInfo {
563  using ConstantClassInfo = DenseMapInfo<ConstantClass *>;
564 
565  static inline ConstantClass *getEmptyKey() {
566  return ConstantClassInfo::getEmptyKey();
567  }
568 
569  static inline ConstantClass *getTombstoneKey() {
570  return ConstantClassInfo::getTombstoneKey();
571  }
572 
573  static unsigned getHashValue(const ConstantClass *CP) {
575  return getHashValue(LookupKey(CP->getType(), ValType(CP, Storage)));
576  }
577 
578  static bool isEqual(const ConstantClass *LHS, const ConstantClass *RHS) {
579  return LHS == RHS;
580  }
581 
582  static unsigned getHashValue(const LookupKey &Val) {
583  return hash_combine(Val.first, Val.second.getHash());
584  }
585 
586  static unsigned getHashValue(const LookupKeyHashed &Val) {
587  return Val.first;
588  }
589 
590  static bool isEqual(const LookupKey &LHS, const ConstantClass *RHS) {
591  if (RHS == getEmptyKey() || RHS == getTombstoneKey())
592  return false;
593  if (LHS.first != RHS->getType())
594  return false;
595  return LHS.second == RHS;
596  }
597 
598  static bool isEqual(const LookupKeyHashed &LHS, const ConstantClass *RHS) {
599  return isEqual(LHS.second, RHS);
600  }
601  };
602 
603 public:
605 
606 private:
607  MapTy Map;
608 
609 public:
610  typename MapTy::iterator begin() { return Map.begin(); }
611  typename MapTy::iterator end() { return Map.end(); }
612 
613  void freeConstants() {
614  for (auto &I : Map)
615  deleteConstant(I);
616  }
617 
618 private:
619  ConstantClass *create(TypeClass *Ty, ValType V, LookupKeyHashed &HashKey) {
620  ConstantClass *Result = V.create(Ty);
621 
622  assert(Result->getType() == Ty && "Type specified is not correct!");
623  Map.insert_as(Result, HashKey);
624 
625  return Result;
626  }
627 
628 public:
629  /// Return the specified constant from the map, creating it if necessary.
630  ConstantClass *getOrCreate(TypeClass *Ty, ValType V) {
631  LookupKey Key(Ty, V);
632  /// Hash once, and reuse it for the lookup and the insertion if needed.
633  LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
634 
635  ConstantClass *Result = nullptr;
636 
637  auto I = Map.find_as(Lookup);
638  if (I == Map.end())
639  Result = create(Ty, V, Lookup);
640  else
641  Result = *I;
642  assert(Result && "Unexpected nullptr");
643 
644  return Result;
645  }
646 
647  /// Remove this constant from the map
648  void remove(ConstantClass *CP) {
649  typename MapTy::iterator I = Map.find(CP);
650  assert(I != Map.end() && "Constant not found in constant table!");
651  assert(*I == CP && "Didn't find correct element?");
652  Map.erase(I);
653  }
654 
656  ConstantClass *CP, Value *From,
657  Constant *To, unsigned NumUpdated = 0,
658  unsigned OperandNo = ~0u) {
659  LookupKey Key(CP->getType(), ValType(Operands, CP));
660  /// Hash once, and reuse it for the lookup and the insertion if needed.
661  LookupKeyHashed Lookup(MapInfo::getHashValue(Key), Key);
662 
663  auto ItMap = Map.find_as(Lookup);
664  if (ItMap != Map.end())
665  return *ItMap;
666 
667  // Update to the new value. Optimize for the case when we have a single
668  // operand that we're changing, but handle bulk updates efficiently.
669  remove(CP);
670  if (NumUpdated == 1) {
671  assert(OperandNo < CP->getNumOperands() && "Invalid index");
672  assert(CP->getOperand(OperandNo) != To && "I didn't contain From!");
673  CP->setOperand(OperandNo, To);
674  } else {
675  for (unsigned I = 0, E = CP->getNumOperands(); I != E; ++I)
676  if (CP->getOperand(I) == From)
677  CP->setOperand(I, To);
678  }
679  Map.insert_as(CP, Lookup);
680  return nullptr;
681  }
682 
683  void dump() const {
684  LLVM_DEBUG(dbgs() << "Constant.cpp: ConstantUniqueMap\n");
685  }
686 };
687 
689  for (auto &I : Map)
690  delete I;
691 }
692 
693 } // end namespace llvm
694 
695 #endif // LLVM_LIB_IR_CONSTANTSCONTEXT_H
llvm::CompareConstantExpr::CompareConstantExpr
CompareConstantExpr(Type *ty, Instruction::OtherOps opc, unsigned short pred, Constant *LHS, Constant *RHS)
Definition: ConstantsContext.h:250
llvm::ShuffleVectorConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::ConstantAggrKeyType::operator==
bool operator==(const ConstantAggrKeyType &X) const
Definition: ConstantsContext.h:356
llvm::InlineAsmKeyType::IsAlignStack
bool IsAlignStack
Definition: ConstantsContext.h:385
llvm::ScalableVectorType
Class to represent scalable SIMD vectors.
Definition: DerivedTypes.h:572
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::CompareConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::InlineAsm::AsmDialect
AsmDialect
Definition: InlineAsm.h:34
llvm::CastConstantExpr::classof
static bool classof(const Value *V)
Definition: ConstantsContext.h:62
llvm::deleteConstant
void deleteConstant(Constant *C)
Definition: Constants.cpp:490
llvm::ConstantAggrKeyType::TypeClass
typename ConstantInfo< ConstantClass >::TypeClass TypeClass
Definition: ConstantsContext.h:373
llvm::Value::SubclassOptionalData
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Definition: Value.h:90
llvm::ConstantUniqueMap::replaceOperandsInPlace
ConstantClass * replaceOperandsInPlace(ArrayRef< Constant * > Operands, ConstantClass *CP, Value *From, Constant *To, unsigned NumUpdated=0, unsigned OperandNo=~0u)
Definition: ConstantsContext.h:655
llvm::isa
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:548
llvm::InlineAsmKeyType::InlineAsmKeyType
InlineAsmKeyType(StringRef AsmString, StringRef Constraints, FunctionType *FTy, bool HasSideEffects, bool IsAlignStack, InlineAsm::AsmDialect AsmDialect, bool canThrow)
Definition: ConstantsContext.h:389
llvm::Instruction::isCast
bool isCast() const
Definition: Instruction.h:172
StringRef.h
llvm::VariadicOperandTraits
VariadicOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:68
llvm::ConstantExprKeyType::getHash
unsigned getHash() const
Definition: ConstantsContext.h:508
C1
instcombine should handle this C2 when C1
Definition: README.txt:263
llvm::SmallVector< int, 4 >
InlineAsm.h
ErrorHandling.h
llvm::CompareConstantExpr::classof
static bool classof(const Value *V)
Definition: ConstantsContext.h:268
llvm::GetElementPtrConstantExpr
GetElementPtrConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
Definition: ConstantsContext.h:213
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
DEFINE_TRANSPARENT_OPERAND_ACCESSORS
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
Definition: OperandTraits.h:125
llvm::ExtractElementConstantExpr::classof
static bool classof(const ConstantExpr *CE)
Definition: ConstantsContext.h:139
llvm::BinaryConstantExpr::BinaryConstantExpr
BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags)
Definition: ConstantsContext.h:71
llvm::ExtractElementConstantExpr::classof
static bool classof(const Value *V)
Definition: ConstantsContext.h:142
llvm::ShuffleVectorInst::isValidOperands
static bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
Definition: Instructions.cpp:2079
Hashing.h
llvm::ConstantUniqueMap< llvm::ConstantExpr >::ValType
typename ConstantInfo< llvm::ConstantExpr >::ValType ValType
Definition: ConstantsContext.h:554
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:357
llvm::ConstantUniqueMap::dump
void dump() const
Definition: ConstantsContext.h:683
llvm::ConstantAggrKeyType::Operands
ArrayRef< Constant * > Operands
Definition: ConstantsContext.h:341
llvm::isEqual
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
Definition: GCNRegPressure.cpp:55
llvm::InlineAsmKeyType::AsmDialect
InlineAsm::AsmDialect AsmDialect
Definition: ConstantsContext.h:386
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
llvm::InlineAsmKeyType::InlineAsmKeyType
InlineAsmKeyType(const InlineAsm *Asm, SmallVectorImpl< Constant * > &)
Definition: ConstantsContext.h:396
llvm::BinaryConstantExpr::classof
static bool classof(const Value *V)
Definition: ConstantsContext.h:89
llvm::ConstantExprKeyType::operator==
bool operator==(const ConstantExpr *CE) const
Definition: ConstantsContext.h:489
llvm::ConstantAggrKeyType::operator==
bool operator==(const ConstantClass *C) const
Definition: ConstantsContext.h:360
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::ConstantExpr::get
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:2236
llvm::ConstantInfo
Definition: ConstantsContext.h:318
llvm::BitmaskEnumDetail::Mask
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
Instruction.h
llvm::cast
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition: Casting.h:565
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::InlineAsmKeyType::TypeClass
ConstantInfo< InlineAsm >::TypeClass TypeClass
Definition: ConstantsContext.h:423
llvm::ConstantAggrKeyType::ConstantAggrKeyType
ConstantAggrKeyType(ArrayRef< Constant * > Operands, const ConstantClass *)
Definition: ConstantsContext.h:345
llvm::OperandTraits
Compile-time customization of User operands.
Definition: User.h:42
Constants.h
llvm::CastConstantExpr::CastConstantExpr
CastConstantExpr(unsigned Opcode, Constant *C, Type *Ty)
Definition: ConstantsContext.h:48
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::InlineAsmKeyType
Definition: ConstantsContext.h:380
llvm::ConstantExprKeyType::TypeClass
ConstantInfo< ConstantExpr >::TypeClass TypeClass
Definition: ConstantsContext.h:515
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::ConstantExprKeyType::create
ConstantExpr * create(TypeClass *Ty) const
Definition: ConstantsContext.h:517
llvm::CastConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
llvm::ShuffleVectorConstantExpr::classof
static bool classof(const Value *V)
Definition: ConstantsContext.h:206
llvm::ConstantUniqueMap::end
MapTy::iterator end()
Definition: ConstantsContext.h:611
canThrow
static bool canThrow(const Value *V)
Definition: WebAssemblyLowerEmscriptenEHSjLj.cpp:394
getOpcode
static Optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
Definition: VPlanSLP.cpp:190
llvm::Instruction::OtherOps
OtherOps
Definition: Instruction.h:801
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
DenseSet.h
llvm::ConstantArray
ConstantArray - Constant Array Declarations.
Definition: Constants.h:410
llvm::BinaryConstantExpr::classof
static bool classof(const ConstantExpr *CE)
Definition: ConstantsContext.h:86
llvm::Instruction
Definition: Instruction.h:42
llvm::ShuffleVectorConstantExpr
ShuffleVectorConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
Definition: ConstantsContext.h:178
OperandTraits.h
llvm::GetElementPtrConstantExpr::classof
static bool classof(const Value *V)
Definition: ConstantsContext.h:239
llvm::ExtractElementConstantExpr::ExtractElementConstantExpr
ExtractElementConstantExpr(Constant *C1, Constant *C2)
Definition: ConstantsContext.h:125
llvm::SelectConstantExpr
SelectConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
Definition: ConstantsContext.h:96
llvm::ArrayRef::slice
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
Definition: ArrayRef.h:194
llvm::ConstantUniqueMap::begin
MapTy::iterator begin()
Definition: ConstantsContext.h:610
llvm::None
const NoneType None
Definition: None.h:24
llvm::InsertElementConstantExpr::classof
static bool classof(const ConstantExpr *CE)
Definition: ConstantsContext.h:167
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
Operands
mir Rename Register Operands
Definition: MIRNamerPass.cpp:74
llvm::ShuffleVectorConstantExpr::ShuffleMaskForBitcode
Constant * ShuffleMaskForBitcode
Definition: ConstantsContext.h:195
llvm::InlineAsm
Definition: InlineAsm.h:32
llvm::VectorType
Base class of all SIMD vector types.
Definition: DerivedTypes.h:389
llvm::ShuffleVectorConstantExpr::classof
static bool classof(const ConstantExpr *CE)
Definition: ConstantsContext.h:203
llvm::DenseSet< llvm::ConstantExpr *, MapInfo >
llvm::ConstantAggrKeyType::create
ConstantClass * create(TypeClass *Ty) const
Definition: ConstantsContext.h:375
llvm::InlineAsmKeyType::CanThrow
bool CanThrow
Definition: ConstantsContext.h:387
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::PointerType::getUnqual
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Definition: DerivedTypes.h:651
llvm::ConstantAggrKeyType
Definition: Constants.h:44
llvm::GetElementPtrConstantExpr::classof
static bool classof(const ConstantExpr *CE)
Definition: ConstantsContext.h:236
llvm::GetElementPtrConstantExpr::getSourceElementType
Type * getSourceElementType() const
Definition: Constants.cpp:2797
llvm::CompareConstantExpr::predicate
unsigned short predicate
Definition: ConstantsContext.h:249
llvm::InlineAsmKeyType::operator==
bool operator==(const InlineAsm *Asm) const
Definition: ConstantsContext.h:409
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:632
ArrayRef.h
llvm::ConstantUniqueMap::getOrCreate
ConstantClass * getOrCreate(TypeClass *Ty, ValType V)
Return the specified constant from the map, creating it if necessary.
Definition: ConstantsContext.h:630
llvm::CompareConstantExpr
Definition: ConstantsContext.h:247
llvm::ConstantAggrKeyType::ConstantAggrKeyType
ConstantAggrKeyType(const ConstantClass *C, SmallVectorImpl< Constant * > &Storage)
Definition: ConstantsContext.h:348
llvm::ConstantVector
Constant Vector Declarations.
Definition: Constants.h:494
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::InlineAsmKeyType::HasSideEffects
bool HasSideEffects
Definition: ConstantsContext.h:384
llvm::InlineAsmKeyType::Constraints
StringRef Constraints
Definition: ConstantsContext.h:382
llvm::InlineAsmKeyType::operator==
bool operator==(const InlineAsmKeyType &X) const
Definition: ConstantsContext.h:402
llvm::InsertElementConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Ptr
@ Ptr
Definition: TargetLibraryInfo.cpp:60
llvm::CastConstantExpr
CastConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to implement...
Definition: ConstantsContext.h:46
llvm::Instruction::isBinaryOp
bool isBinaryOp() const
Definition: Instruction.h:169
llvm::ConstantUniqueMap< llvm::ConstantExpr >::TypeClass
typename ConstantInfo< llvm::ConstantExpr >::TypeClass TypeClass
Definition: ConstantsContext.h:555
llvm::ConstantStruct
Definition: Constants.h:442
llvm::size
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:1571
llvm::SelectConstantExpr::classof
static bool classof(const ConstantExpr *CE)
Definition: ConstantsContext.h:112
llvm::CastConstantExpr::classof
static bool classof(const ConstantExpr *CE)
Definition: ConstantsContext.h:59
llvm::InsertElementConstantExpr::classof
static bool classof(const Value *V)
Definition: ConstantsContext.h:170
llvm::ShuffleVectorConstantExpr::ShuffleVectorConstantExpr
ShuffleVectorConstantExpr(Constant *C1, Constant *C2, ArrayRef< int > Mask)
Definition: ConstantsContext.h:180
llvm::ArrayRef< int >
None.h
llvm::StructType
Class to represent struct types.
Definition: DerivedTypes.h:213
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::ConstantUniqueMap< llvm::ConstantExpr >::LookupKeyHashed
std::pair< unsigned, LookupKey > LookupKeyHashed
Key and hash together, so that we compute the hash only once and reuse it.
Definition: ConstantsContext.h:559
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::CompareConstantExpr::classof
static bool classof(const ConstantExpr *CE)
Definition: ConstantsContext.h:264
llvm::ConstantExprKeyType
Definition: ConstantsContext.h:432
llvm::InlineAsmKeyType::create
InlineAsm * create(TypeClass *Ty) const
Definition: ConstantsContext.h:425
llvm::ConstantAggrKeyType::ConstantAggrKeyType
ConstantAggrKeyType(ArrayRef< Constant * > Operands)
Definition: ConstantsContext.h:343
llvm::MCID::Select
@ Select
Definition: MCInstrDesc.h:164
llvm::HexagonISD::CP
@ CP
Definition: HexagonISelLowering.h:53
llvm::SelectConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Constant.h
llvm::ConstantExpr
A constant value that is initialized with an expression using other constant values.
Definition: Constants.h:972
llvm::PPC::getPredicate
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
Definition: PPCPredicates.h:87
llvm::InlineAsmKeyType::FTy
FunctionType * FTy
Definition: ConstantsContext.h:383
uint16_t
llvm::ConstantExprKeyType::ConstantExprKeyType
ConstantExprKeyType(unsigned Opcode, ArrayRef< Constant * > Ops, unsigned short SubclassData=0, unsigned short SubclassOptionalData=0, ArrayRef< int > ShuffleMask=None, Type *ExplicitTy=nullptr)
Definition: ConstantsContext.h:454
llvm::SmallVectorImpl::assign
void assign(size_type NumElts, ValueParamT Elt)
Definition: SmallVector.h:690
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:152
Casting.h
llvm::ConstantUniqueMap::remove
void remove(ConstantClass *CP)
Remove this constant from the map.
Definition: ConstantsContext.h:648
llvm::InlineAsmKeyType::getHash
unsigned getHash() const
Definition: ConstantsContext.h:418
Lookup
static int Lookup(ArrayRef< TableEntry > Table, unsigned Opcode)
Definition: X86FloatingPoint.cpp:597
llvm::SelectConstantExpr::classof
static bool classof(const Value *V)
Definition: ConstantsContext.h:115
llvm::ExtractElementConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
llvm::GetElementPtrConstantExpr::getResultElementType
Type * getResultElementType() const
Definition: Constants.cpp:2801
llvm::BinaryConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
Instructions.h
llvm::InsertElementConstantExpr
InsertElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to ...
Definition: ConstantsContext.h:150
SmallVector.h
llvm::hash_combine
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:605
llvm::hash_combine_range
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition: Hashing.h:483
llvm::BinaryConstantExpr
BinaryConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to impleme...
Definition: ConstantsContext.h:69
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:164
llvm::FixedNumOperandTraits
FixedNumOperandTraits - determine the allocation regime of the Use array when it is a prefix to the U...
Definition: OperandTraits.h:30
llvm::ConstantUniqueMap< llvm::ConstantExpr >::LookupKey
std::pair< TypeClass *, ValType > LookupKey
Definition: ConstantsContext.h:556
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
DenseMapInfo.h
llvm::SelectConstantExpr::SelectConstantExpr
SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
Definition: ConstantsContext.h:98
DerivedTypes.h
llvm::InlineAsmKeyType::AsmString
StringRef AsmString
Definition: ConstantsContext.h:381
llvm::HexStyle::Asm
@ Asm
0ffh
Definition: MCInstPrinter.h:34
pred
hexagon gen pred
Definition: HexagonGenPredicate.cpp:134
llvm::User::Op
Use & Op()
Definition: User.h:133
llvm::GetElementPtrConstantExpr::DECLARE_TRANSPARENT_OPERAND_ACCESSORS
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
Transparently provide more efficient getOperand methods.
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
raw_ostream.h
llvm::ShuffleVectorConstantExpr::ShuffleMask
SmallVector< int, 4 > ShuffleMask
Definition: ConstantsContext.h:194
llvm::ConstantAggrKeyType::getHash
unsigned getHash() const
Definition: ConstantsContext.h:369
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
Debug.h
llvm::ConstantExprKeyType::ConstantExprKeyType
ConstantExprKeyType(ArrayRef< Constant * > Operands, const ConstantExpr *CE)
Definition: ConstantsContext.h:463
llvm::ConstantExprKeyType::ConstantExprKeyType
ConstantExprKeyType(const ConstantExpr *CE, SmallVectorImpl< Constant * > &Storage)
Definition: ConstantsContext.h:470
llvm::ShuffleVectorInst::convertShuffleMaskForBitcode
static Constant * convertShuffleMaskForBitcode(ArrayRef< int > Mask, Type *ResultTy)
Definition: Instructions.cpp:2160
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:153
llvm::InsertElementConstantExpr::InsertElementConstantExpr
InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
Definition: ConstantsContext.h:152
llvm::ConstantUniqueMap::freeConstants
void freeConstants()
Definition: ConstantsContext.h:613
llvm::detail::DenseSetImpl< llvm::ConstantExpr *, DenseMap< llvm::ConstantExpr *, detail::DenseSetEmpty, MapInfo, detail::DenseSetPair< llvm::ConstantExpr * > >, MapInfo >::iterator
Iterator iterator
Definition: DenseSet.h:170
llvm::ExtractElementConstantExpr
ExtractElementConstantExpr - This class is private to Constants.cpp, and is used behind the scenes to...
Definition: ConstantsContext.h:123
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:103
llvm::GetElementPtrConstantExpr::Create
static GetElementPtrConstantExpr * Create(Type *SrcElementTy, Constant *C, ArrayRef< Constant * > IdxList, Type *DestTy, unsigned Flags)
Definition: ConstantsContext.h:221
llvm::ConstantExprKeyType::operator==
bool operator==(const ConstantExprKeyType &X) const
Definition: ConstantsContext.h:483