LLVM  16.0.0git
Record.cpp
Go to the documentation of this file.
1 //===- Record.cpp - Record implementation ---------------------------------===//
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 // Implement the tablegen record classes.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/TableGen/Record.h"
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/FoldingSet.h"
17 #include "llvm/ADT/SmallString.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/Config/llvm-config.h"
23 #include "llvm/Support/Allocator.h"
24 #include "llvm/Support/Casting.h"
25 #include "llvm/Support/Compiler.h"
27 #include "llvm/Support/SMLoc.h"
29 #include "llvm/TableGen/Error.h"
30 #include <cassert>
31 #include <cstdint>
32 #include <map>
33 #include <memory>
34 #include <string>
35 #include <utility>
36 #include <vector>
37 
38 using namespace llvm;
39 
40 #define DEBUG_TYPE "tblgen-records"
41 
42 //===----------------------------------------------------------------------===//
43 // Context
44 //===----------------------------------------------------------------------===//
45 
46 namespace llvm {
47 namespace detail {
48 /// This class represents the internal implementation of the RecordKeeper.
49 /// It contains all of the contextual static state of the Record classes. It is
50 /// kept out-of-line to simplify dependencies, and also make it easier for
51 /// internal classes to access the uniquer state of the keeper.
55  SharedDagRecTy(RK), AnyRecord(RK, 0), TheUnsetInit(RK),
59 
61  std::vector<BitsRecTy *> SharedBitsRecTys;
66 
71 
73  std::map<int64_t, IntInit *> TheIntInitPool;
92 
93  unsigned AnonCounter;
94  unsigned LastRecordID;
95 };
96 } // namespace detail
97 } // namespace llvm
98 
99 //===----------------------------------------------------------------------===//
100 // Type implementations
101 //===----------------------------------------------------------------------===//
102 
103 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
105 #endif
106 
108  if (!ListTy)
109  ListTy = new (RK.getImpl().Allocator) ListRecTy(this);
110  return ListTy;
111 }
112 
114  assert(RHS && "NULL pointer");
115  return Kind == RHS->getRecTyKind();
116 }
117 
118 bool RecTy::typeIsA(const RecTy *RHS) const { return this == RHS; }
119 
121  return &RK.getImpl().SharedBitRecTy;
122 }
123 
125  if (RecTy::typeIsConvertibleTo(RHS) || RHS->getRecTyKind() == IntRecTyKind)
126  return true;
127  if (const BitsRecTy *BitsTy = dyn_cast<BitsRecTy>(RHS))
128  return BitsTy->getNumBits() == 1;
129  return false;
130 }
131 
133  detail::RecordKeeperImpl &RKImpl = RK.getImpl();
134  if (Sz >= RKImpl.SharedBitsRecTys.size())
135  RKImpl.SharedBitsRecTys.resize(Sz + 1);
136  BitsRecTy *&Ty = RKImpl.SharedBitsRecTys[Sz];
137  if (!Ty)
138  Ty = new (RKImpl.Allocator) BitsRecTy(RK, Sz);
139  return Ty;
140 }
141 
142 std::string BitsRecTy::getAsString() const {
143  return "bits<" + utostr(Size) + ">";
144 }
145 
147  if (RecTy::typeIsConvertibleTo(RHS)) //argument and the sender are same type
148  return cast<BitsRecTy>(RHS)->Size == Size;
149  RecTyKind kind = RHS->getRecTyKind();
150  return (kind == BitRecTyKind && Size == 1) || (kind == IntRecTyKind);
151 }
152 
153 bool BitsRecTy::typeIsA(const RecTy *RHS) const {
154  if (const BitsRecTy *RHSb = dyn_cast<BitsRecTy>(RHS))
155  return RHSb->Size == Size;
156  return false;
157 }
158 
160  return &RK.getImpl().SharedIntRecTy;
161 }
162 
164  RecTyKind kind = RHS->getRecTyKind();
165  return kind==BitRecTyKind || kind==BitsRecTyKind || kind==IntRecTyKind;
166 }
167 
169  return &RK.getImpl().SharedStringRecTy;
170 }
171 
172 std::string StringRecTy::getAsString() const {
173  return "string";
174 }
175 
177  RecTyKind Kind = RHS->getRecTyKind();
178  return Kind == StringRecTyKind;
179 }
180 
181 std::string ListRecTy::getAsString() const {
182  return "list<" + ElementTy->getAsString() + ">";
183 }
184 
186  if (const auto *ListTy = dyn_cast<ListRecTy>(RHS))
187  return ElementTy->typeIsConvertibleTo(ListTy->getElementType());
188  return false;
189 }
190 
191 bool ListRecTy::typeIsA(const RecTy *RHS) const {
192  if (const ListRecTy *RHSl = dyn_cast<ListRecTy>(RHS))
193  return getElementType()->typeIsA(RHSl->getElementType());
194  return false;
195 }
196 
198  return &RK.getImpl().SharedDagRecTy;
199 }
200 
201 std::string DagRecTy::getAsString() const {
202  return "dag";
203 }
204 
206  ArrayRef<Record *> Classes) {
207  ID.AddInteger(Classes.size());
208  for (Record *R : Classes)
209  ID.AddPointer(R);
210 }
211 
213  ArrayRef<Record *> UnsortedClasses) {
214  detail::RecordKeeperImpl &RKImpl = RK.getImpl();
215  if (UnsortedClasses.empty())
216  return &RKImpl.AnyRecord;
217 
218  FoldingSet<RecordRecTy> &ThePool = RKImpl.RecordTypePool;
219 
220  SmallVector<Record *, 4> Classes(UnsortedClasses.begin(),
221  UnsortedClasses.end());
222  llvm::sort(Classes, [](Record *LHS, Record *RHS) {
223  return LHS->getNameInitAsString() < RHS->getNameInitAsString();
224  });
225 
227  ProfileRecordRecTy(ID, Classes);
228 
229  void *IP = nullptr;
230  if (RecordRecTy *Ty = ThePool.FindNodeOrInsertPos(ID, IP))
231  return Ty;
232 
233 #ifndef NDEBUG
234  // Check for redundancy.
235  for (unsigned i = 0; i < Classes.size(); ++i) {
236  for (unsigned j = 0; j < Classes.size(); ++j) {
237  assert(i == j || !Classes[i]->isSubClassOf(Classes[j]));
238  }
239  assert(&Classes[0]->getRecords() == &Classes[i]->getRecords());
240  }
241 #endif
242 
243  void *Mem = RKImpl.Allocator.Allocate(
244  totalSizeToAlloc<Record *>(Classes.size()), alignof(RecordRecTy));
245  RecordRecTy *Ty = new (Mem) RecordRecTy(RK, Classes.size());
246  std::uninitialized_copy(Classes.begin(), Classes.end(),
247  Ty->getTrailingObjects<Record *>());
248  ThePool.InsertNode(Ty, IP);
249  return Ty;
250 }
252  assert(Class && "unexpected null class");
253  return get(Class->getRecords(), Class);
254 }
255 
258 }
259 
260 std::string RecordRecTy::getAsString() const {
261  if (NumClasses == 1)
262  return getClasses()[0]->getNameInitAsString();
263 
264  std::string Str = "{";
265  bool First = true;
266  for (Record *R : getClasses()) {
267  if (!First)
268  Str += ", ";
269  First = false;
270  Str += R->getNameInitAsString();
271  }
272  Str += "}";
273  return Str;
274 }
275 
276 bool RecordRecTy::isSubClassOf(Record *Class) const {
277  return llvm::any_of(getClasses(), [Class](Record *MySuperClass) {
278  return MySuperClass == Class ||
279  MySuperClass->isSubClassOf(Class);
280  });
281 }
282 
284  if (this == RHS)
285  return true;
286 
287  const RecordRecTy *RTy = dyn_cast<RecordRecTy>(RHS);
288  if (!RTy)
289  return false;
290 
291  return llvm::all_of(RTy->getClasses(), [this](Record *TargetClass) {
292  return isSubClassOf(TargetClass);
293  });
294 }
295 
296 bool RecordRecTy::typeIsA(const RecTy *RHS) const {
297  return typeIsConvertibleTo(RHS);
298 }
299 
301  SmallVector<Record *, 4> CommonSuperClasses;
302  SmallVector<Record *, 4> Stack(T1->classes_begin(), T1->classes_end());
303 
304  while (!Stack.empty()) {
305  Record *R = Stack.pop_back_val();
306 
307  if (T2->isSubClassOf(R)) {
308  CommonSuperClasses.push_back(R);
309  } else {
310  R->getDirectSuperClasses(Stack);
311  }
312  }
313 
314  return RecordRecTy::get(T1->getRecordKeeper(), CommonSuperClasses);
315 }
316 
318  if (T1 == T2)
319  return T1;
320 
321  if (RecordRecTy *RecTy1 = dyn_cast<RecordRecTy>(T1)) {
322  if (RecordRecTy *RecTy2 = dyn_cast<RecordRecTy>(T2))
323  return resolveRecordTypes(RecTy1, RecTy2);
324  }
325 
326  if (T1->typeIsConvertibleTo(T2))
327  return T2;
328  if (T2->typeIsConvertibleTo(T1))
329  return T1;
330 
331  if (ListRecTy *ListTy1 = dyn_cast<ListRecTy>(T1)) {
332  if (ListRecTy *ListTy2 = dyn_cast<ListRecTy>(T2)) {
333  RecTy* NewType = resolveTypes(ListTy1->getElementType(),
334  ListTy2->getElementType());
335  if (NewType)
336  return NewType->getListTy();
337  }
338  }
339 
340  return nullptr;
341 }
342 
343 //===----------------------------------------------------------------------===//
344 // Initializer implementations
345 //===----------------------------------------------------------------------===//
346 
347 void Init::anchor() {}
348 
349 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
350 LLVM_DUMP_METHOD void Init::dump() const { return print(errs()); }
351 #endif
352 
354  if (auto *TyInit = dyn_cast<TypedInit>(this))
355  return TyInit->getType()->getRecordKeeper();
356  return cast<UnsetInit>(this)->getRecordKeeper();
357 }
358 
360  return &RK.getImpl().TheUnsetInit;
361 }
362 
364  return const_cast<UnsetInit *>(this);
365 }
366 
368  return const_cast<UnsetInit *>(this);
369 }
370 
372  return V ? &RK.getImpl().TrueBitInit : &RK.getImpl().FalseBitInit;
373 }
374 
376  if (isa<BitRecTy>(Ty))
377  return const_cast<BitInit *>(this);
378 
379  if (isa<IntRecTy>(Ty))
381 
382  if (auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
383  // Can only convert single bit.
384  if (BRT->getNumBits() == 1)
385  return BitsInit::get(getRecordKeeper(), const_cast<BitInit *>(this));
386  }
387 
388  return nullptr;
389 }
390 
391 static void
393  ID.AddInteger(Range.size());
394 
395  for (Init *I : Range)
396  ID.AddPointer(I);
397 }
398 
401  ProfileBitsInit(ID, Range);
402 
403  detail::RecordKeeperImpl &RKImpl = RK.getImpl();
404  void *IP = nullptr;
405  if (BitsInit *I = RKImpl.TheBitsInitPool.FindNodeOrInsertPos(ID, IP))
406  return I;
407 
408  void *Mem = RKImpl.Allocator.Allocate(totalSizeToAlloc<Init *>(Range.size()),
409  alignof(BitsInit));
410  BitsInit *I = new (Mem) BitsInit(RK, Range.size());
411  std::uninitialized_copy(Range.begin(), Range.end(),
412  I->getTrailingObjects<Init *>());
413  RKImpl.TheBitsInitPool.InsertNode(I, IP);
414  return I;
415 }
416 
418  ProfileBitsInit(ID, makeArrayRef(getTrailingObjects<Init *>(), NumBits));
419 }
420 
422  if (isa<BitRecTy>(Ty)) {
423  if (getNumBits() != 1) return nullptr; // Only accept if just one bit!
424  return getBit(0);
425  }
426 
427  if (auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
428  // If the number of bits is right, return it. Otherwise we need to expand
429  // or truncate.
430  if (getNumBits() != BRT->getNumBits()) return nullptr;
431  return const_cast<BitsInit *>(this);
432  }
433 
434  if (isa<IntRecTy>(Ty)) {
435  int64_t Result = 0;
436  for (unsigned i = 0, e = getNumBits(); i != e; ++i)
437  if (auto *Bit = dyn_cast<BitInit>(getBit(i)))
438  Result |= static_cast<int64_t>(Bit->getValue()) << i;
439  else
440  return nullptr;
441  return IntInit::get(getRecordKeeper(), Result);
442  }
443 
444  return nullptr;
445 }
446 
447 Init *
449  SmallVector<Init *, 16> NewBits(Bits.size());
450 
451  for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
452  if (Bits[i] >= getNumBits())
453  return nullptr;
454  NewBits[i] = getBit(Bits[i]);
455  }
456  return BitsInit::get(getRecordKeeper(), NewBits);
457 }
458 
459 bool BitsInit::isConcrete() const {
460  for (unsigned i = 0, e = getNumBits(); i != e; ++i) {
461  if (!getBit(i)->isConcrete())
462  return false;
463  }
464  return true;
465 }
466 
467 std::string BitsInit::getAsString() const {
468  std::string Result = "{ ";
469  for (unsigned i = 0, e = getNumBits(); i != e; ++i) {
470  if (i) Result += ", ";
471  if (Init *Bit = getBit(e-i-1))
472  Result += Bit->getAsString();
473  else
474  Result += "*";
475  }
476  return Result + " }";
477 }
478 
479 // resolveReferences - If there are any field references that refer to fields
480 // that have been filled in, we can propagate the values now.
482  bool Changed = false;
484 
485  Init *CachedBitVarRef = nullptr;
486  Init *CachedBitVarResolved = nullptr;
487 
488  for (unsigned i = 0, e = getNumBits(); i != e; ++i) {
489  Init *CurBit = getBit(i);
490  Init *NewBit = CurBit;
491 
492  if (VarBitInit *CurBitVar = dyn_cast<VarBitInit>(CurBit)) {
493  if (CurBitVar->getBitVar() != CachedBitVarRef) {
494  CachedBitVarRef = CurBitVar->getBitVar();
495  CachedBitVarResolved = CachedBitVarRef->resolveReferences(R);
496  }
497  assert(CachedBitVarResolved && "Unresolved bitvar reference");
498  NewBit = CachedBitVarResolved->getBit(CurBitVar->getBitNum());
499  } else {
500  // getBit(0) implicitly converts int and bits<1> values to bit.
501  NewBit = CurBit->resolveReferences(R)->getBit(0);
502  }
503 
504  if (isa<UnsetInit>(NewBit) && R.keepUnsetBits())
505  NewBit = CurBit;
506  NewBits[i] = NewBit;
507  Changed |= CurBit != NewBit;
508  }
509 
510  if (Changed)
511  return BitsInit::get(getRecordKeeper(), NewBits);
512 
513  return const_cast<BitsInit *>(this);
514 }
515 
517  IntInit *&I = RK.getImpl().TheIntInitPool[V];
518  if (!I)
519  I = new (RK.getImpl().Allocator) IntInit(RK, V);
520  return I;
521 }
522 
523 std::string IntInit::getAsString() const {
524  return itostr(Value);
525 }
526 
527 static bool canFitInBitfield(int64_t Value, unsigned NumBits) {
528  // For example, with NumBits == 4, we permit Values from [-7 .. 15].
529  return (NumBits >= sizeof(Value) * 8) ||
530  (Value >> NumBits == 0) || (Value >> (NumBits-1) == -1);
531 }
532 
534  if (isa<IntRecTy>(Ty))
535  return const_cast<IntInit *>(this);
536 
537  if (isa<BitRecTy>(Ty)) {
538  int64_t Val = getValue();
539  if (Val != 0 && Val != 1) return nullptr; // Only accept 0 or 1 for a bit!
540  return BitInit::get(getRecordKeeper(), Val != 0);
541  }
542 
543  if (auto *BRT = dyn_cast<BitsRecTy>(Ty)) {
544  int64_t Value = getValue();
545  // Make sure this bitfield is large enough to hold the integer value.
546  if (!canFitInBitfield(Value, BRT->getNumBits()))
547  return nullptr;
548 
549  SmallVector<Init *, 16> NewBits(BRT->getNumBits());
550  for (unsigned i = 0; i != BRT->getNumBits(); ++i)
551  NewBits[i] =
552  BitInit::get(getRecordKeeper(), Value & ((i < 64) ? (1LL << i) : 0));
553 
554  return BitsInit::get(getRecordKeeper(), NewBits);
555  }
556 
557  return nullptr;
558 }
559 
560 Init *
562  SmallVector<Init *, 16> NewBits(Bits.size());
563 
564  for (unsigned i = 0, e = Bits.size(); i != e; ++i) {
565  if (Bits[i] >= 64)
566  return nullptr;
567 
568  NewBits[i] =
569  BitInit::get(getRecordKeeper(), Value & (INT64_C(1) << Bits[i]));
570  }
571  return BitsInit::get(getRecordKeeper(), NewBits);
572 }
573 
575  return new (RK.getImpl().Allocator) AnonymousNameInit(RK, V);
576 }
577 
580 }
581 
582 std::string AnonymousNameInit::getAsString() const {
583  return "anonymous_" + utostr(Value);
584 }
585 
587  auto *Old = const_cast<Init *>(static_cast<const Init *>(this));
588  auto *New = R.resolve(Old);
589  New = New ? New : Old;
590  if (R.isFinal())
591  if (auto *Anonymous = dyn_cast<AnonymousNameInit>(New))
592  return Anonymous->getNameInit();
593  return New;
594 }
595 
597  detail::RecordKeeperImpl &RKImpl = RK.getImpl();
598  auto &InitMap = Fmt == SF_String ? RKImpl.StringInitStringPool
599  : RKImpl.StringInitCodePool;
600  auto &Entry = *InitMap.insert(std::make_pair(V, nullptr)).first;
601  if (!Entry.second)
602  Entry.second = new (RKImpl.Allocator) StringInit(RK, Entry.getKey(), Fmt);
603  return Entry.second;
604 }
605 
607  if (isa<StringRecTy>(Ty))
608  return const_cast<StringInit *>(this);
609 
610  return nullptr;
611 }
612 
614  ArrayRef<Init *> Range,
615  RecTy *EltTy) {
616  ID.AddInteger(Range.size());
617  ID.AddPointer(EltTy);
618 
619  for (Init *I : Range)
620  ID.AddPointer(I);
621 }
622 
625  ProfileListInit(ID, Range, EltTy);
626 
628  void *IP = nullptr;
629  if (ListInit *I = RK.TheListInitPool.FindNodeOrInsertPos(ID, IP))
630  return I;
631 
632  assert(Range.empty() || !isa<TypedInit>(Range[0]) ||
633  cast<TypedInit>(Range[0])->getType()->typeIsConvertibleTo(EltTy));
634 
635  void *Mem = RK.Allocator.Allocate(totalSizeToAlloc<Init *>(Range.size()),
636  alignof(ListInit));
637  ListInit *I = new (Mem) ListInit(Range.size(), EltTy);
638  std::uninitialized_copy(Range.begin(), Range.end(),
639  I->getTrailingObjects<Init *>());
640  RK.TheListInitPool.InsertNode(I, IP);
641  return I;
642 }
643 
645  RecTy *EltTy = cast<ListRecTy>(getType())->getElementType();
646 
647  ProfileListInit(ID, getValues(), EltTy);
648 }
649 
651  if (getType() == Ty)
652  return const_cast<ListInit*>(this);
653 
654  if (auto *LRT = dyn_cast<ListRecTy>(Ty)) {
655  SmallVector<Init*, 8> Elements;
656  Elements.reserve(getValues().size());
657 
658  // Verify that all of the elements of the list are subclasses of the
659  // appropriate class!
660  bool Changed = false;
661  RecTy *ElementType = LRT->getElementType();
662  for (Init *I : getValues())
663  if (Init *CI = I->convertInitializerTo(ElementType)) {
664  Elements.push_back(CI);
665  if (CI != I)
666  Changed = true;
667  } else
668  return nullptr;
669 
670  if (!Changed)
671  return const_cast<ListInit*>(this);
672  return ListInit::get(Elements, ElementType);
673  }
674 
675  return nullptr;
676 }
677 
679  if (Elements.size() == 1) {
680  if (Elements[0] >= size())
681  return nullptr;
682  return getElement(Elements[0]);
683  }
684 
686  Vals.reserve(Elements.size());
687  for (unsigned Element : Elements) {
688  if (Element >= size())
689  return nullptr;
690  Vals.push_back(getElement(Element));
691  }
692  return ListInit::get(Vals, getElementType());
693 }
694 
696  assert(i < NumValues && "List element index out of range!");
697  DefInit *DI = dyn_cast<DefInit>(getElement(i));
698  if (!DI)
699  PrintFatalError("Expected record in list!");
700  return DI->getDef();
701 }
702 
704  SmallVector<Init*, 8> Resolved;
705  Resolved.reserve(size());
706  bool Changed = false;
707 
708  for (Init *CurElt : getValues()) {
709  Init *E = CurElt->resolveReferences(R);
710  Changed |= E != CurElt;
711  Resolved.push_back(E);
712  }
713 
714  if (Changed)
715  return ListInit::get(Resolved, getElementType());
716  return const_cast<ListInit *>(this);
717 }
718 
719 bool ListInit::isComplete() const {
720  for (Init *Element : *this) {
721  if (!Element->isComplete())
722  return false;
723  }
724  return true;
725 }
726 
727 bool ListInit::isConcrete() const {
728  for (Init *Element : *this) {
729  if (!Element->isConcrete())
730  return false;
731  }
732  return true;
733 }
734 
735 std::string ListInit::getAsString() const {
736  std::string Result = "[";
737  const char *sep = "";
738  for (Init *Element : *this) {
739  Result += sep;
740  sep = ", ";
741  Result += Element->getAsString();
742  }
743  return Result + "]";
744 }
745 
746 Init *OpInit::getBit(unsigned Bit) const {
748  return const_cast<OpInit*>(this);
749  return VarBitInit::get(const_cast<OpInit*>(this), Bit);
750 }
751 
752 static void
754  ID.AddInteger(Opcode);
755  ID.AddPointer(Op);
756  ID.AddPointer(Type);
757 }
758 
762 
763  detail::RecordKeeperImpl &RK = Type->getRecordKeeper().getImpl();
764  void *IP = nullptr;
765  if (UnOpInit *I = RK.TheUnOpInitPool.FindNodeOrInsertPos(ID, IP))
766  return I;
767 
768  UnOpInit *I = new (RK.Allocator) UnOpInit(Opc, LHS, Type);
769  RK.TheUnOpInitPool.InsertNode(I, IP);
770  return I;
771 }
772 
775 }
776 
777 Init *UnOpInit::Fold(Record *CurRec, bool IsFinal) const {
779  switch (getOpcode()) {
780  case CAST:
781  if (isa<StringRecTy>(getType())) {
782  if (StringInit *LHSs = dyn_cast<StringInit>(LHS))
783  return LHSs;
784 
785  if (DefInit *LHSd = dyn_cast<DefInit>(LHS))
786  return StringInit::get(RK, LHSd->getAsString());
787 
788  if (IntInit *LHSi = dyn_cast_or_null<IntInit>(
790  return StringInit::get(RK, LHSi->getAsString());
791 
792  } else if (isa<RecordRecTy>(getType())) {
793  if (StringInit *Name = dyn_cast<StringInit>(LHS)) {
794  if (!CurRec && !IsFinal)
795  break;
796  assert(CurRec && "NULL pointer");
797  Record *D;
798 
799  // Self-references are allowed, but their resolution is delayed until
800  // the final resolve to ensure that we get the correct type for them.
801  auto *Anonymous = dyn_cast<AnonymousNameInit>(CurRec->getNameInit());
802  if (Name == CurRec->getNameInit() ||
803  (Anonymous && Name == Anonymous->getNameInit())) {
804  if (!IsFinal)
805  break;
806  D = CurRec;
807  } else {
808  D = CurRec->getRecords().getDef(Name->getValue());
809  if (!D) {
810  if (IsFinal)
811  PrintFatalError(CurRec->getLoc(),
812  Twine("Undefined reference to record: '") +
813  Name->getValue() + "'\n");
814  break;
815  }
816  }
817 
818  DefInit *DI = DefInit::get(D);
819  if (!DI->getType()->typeIsA(getType())) {
820  PrintFatalError(CurRec->getLoc(),
821  Twine("Expected type '") +
822  getType()->getAsString() + "', got '" +
823  DI->getType()->getAsString() + "' in: " +
824  getAsString() + "\n");
825  }
826  return DI;
827  }
828  }
829 
830  if (Init *NewInit = LHS->convertInitializerTo(getType()))
831  return NewInit;
832  break;
833 
834  case NOT:
835  if (IntInit *LHSi = dyn_cast_or_null<IntInit>(
837  return IntInit::get(RK, LHSi->getValue() ? 0 : 1);
838  break;
839 
840  case HEAD:
841  if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
842  assert(!LHSl->empty() && "Empty list in head");
843  return LHSl->getElement(0);
844  }
845  break;
846 
847  case TAIL:
848  if (ListInit *LHSl = dyn_cast<ListInit>(LHS)) {
849  assert(!LHSl->empty() && "Empty list in tail");
850  // Note the +1. We can't just pass the result of getValues()
851  // directly.
852  return ListInit::get(LHSl->getValues().slice(1), LHSl->getElementType());
853  }
854  break;
855 
856  case SIZE:
857  if (ListInit *LHSl = dyn_cast<ListInit>(LHS))
858  return IntInit::get(RK, LHSl->size());
859  if (DagInit *LHSd = dyn_cast<DagInit>(LHS))
860  return IntInit::get(RK, LHSd->arg_size());
861  if (StringInit *LHSs = dyn_cast<StringInit>(LHS))
862  return IntInit::get(RK, LHSs->getValue().size());
863  break;
864 
865  case EMPTY:
866  if (ListInit *LHSl = dyn_cast<ListInit>(LHS))
867  return IntInit::get(RK, LHSl->empty());
868  if (DagInit *LHSd = dyn_cast<DagInit>(LHS))
869  return IntInit::get(RK, LHSd->arg_empty());
870  if (StringInit *LHSs = dyn_cast<StringInit>(LHS))
871  return IntInit::get(RK, LHSs->getValue().empty());
872  break;
873 
874  case GETDAGOP:
875  if (DagInit *Dag = dyn_cast<DagInit>(LHS)) {
876  DefInit *DI = DefInit::get(Dag->getOperatorAsDef({}));
877  if (!DI->getType()->typeIsA(getType())) {
878  PrintFatalError(CurRec->getLoc(),
879  Twine("Expected type '") +
880  getType()->getAsString() + "', got '" +
881  DI->getType()->getAsString() + "' in: " +
882  getAsString() + "\n");
883  } else {
884  return DI;
885  }
886  }
887  break;
888  }
889  return const_cast<UnOpInit *>(this);
890 }
891 
893  Init *lhs = LHS->resolveReferences(R);
894 
895  if (LHS != lhs || (R.isFinal() && getOpcode() == CAST))
896  return (UnOpInit::get(getOpcode(), lhs, getType()))
897  ->Fold(R.getCurrentRecord(), R.isFinal());
898  return const_cast<UnOpInit *>(this);
899 }
900 
901 std::string UnOpInit::getAsString() const {
902  std::string Result;
903  switch (getOpcode()) {
904  case CAST: Result = "!cast<" + getType()->getAsString() + ">"; break;
905  case NOT: Result = "!not"; break;
906  case HEAD: Result = "!head"; break;
907  case TAIL: Result = "!tail"; break;
908  case SIZE: Result = "!size"; break;
909  case EMPTY: Result = "!empty"; break;
910  case GETDAGOP: Result = "!getdagop"; break;
911  }
912  return Result + "(" + LHS->getAsString() + ")";
913 }
914 
915 static void
917  RecTy *Type) {
918  ID.AddInteger(Opcode);
919  ID.AddPointer(LHS);
920  ID.AddPointer(RHS);
921  ID.AddPointer(Type);
922 }
923 
927 
928  detail::RecordKeeperImpl &RK = LHS->getRecordKeeper().getImpl();
929  void *IP = nullptr;
930  if (BinOpInit *I = RK.TheBinOpInitPool.FindNodeOrInsertPos(ID, IP))
931  return I;
932 
933  BinOpInit *I = new (RK.Allocator) BinOpInit(Opc, LHS, RHS, Type);
934  RK.TheBinOpInitPool.InsertNode(I, IP);
935  return I;
936 }
937 
940 }
941 
943  const StringInit *I1) {
945  Concat.append(I1->getValue());
946  return StringInit::get(
947  I0->getRecordKeeper(), Concat,
948  StringInit::determineFormat(I0->getFormat(), I1->getFormat()));
949 }
950 
952  const StringInit *Delim) {
953  if (List->size() == 0)
954  return StringInit::get(List->getRecordKeeper(), "");
955  StringInit *Element = dyn_cast<StringInit>(List->getElement(0));
956  if (!Element)
957  return nullptr;
958  SmallString<80> Result(Element->getValue());
960 
961  for (unsigned I = 1, E = List->size(); I < E; ++I) {
962  Result.append(Delim->getValue());
963  StringInit *Element = dyn_cast<StringInit>(List->getElement(I));
964  if (!Element)
965  return nullptr;
966  Result.append(Element->getValue());
967  Fmt = StringInit::determineFormat(Fmt, Element->getFormat());
968  }
969  return StringInit::get(List->getRecordKeeper(), Result, Fmt);
970 }
971 
973  const StringInit *Delim) {
974  RecordKeeper &RK = List->getRecordKeeper();
975  if (List->size() == 0)
976  return StringInit::get(RK, "");
977  IntInit *Element = dyn_cast_or_null<IntInit>(
978  List->getElement(0)->convertInitializerTo(IntRecTy::get(RK)));
979  if (!Element)
980  return nullptr;
981  SmallString<80> Result(Element->getAsString());
982 
983  for (unsigned I = 1, E = List->size(); I < E; ++I) {
984  Result.append(Delim->getValue());
985  IntInit *Element = dyn_cast_or_null<IntInit>(
986  List->getElement(I)->convertInitializerTo(IntRecTy::get(RK)));
987  if (!Element)
988  return nullptr;
989  Result.append(Element->getAsString());
990  }
991  return StringInit::get(RK, Result);
992 }
993 
995  // Shortcut for the common case of concatenating two strings.
996  if (const StringInit *I0s = dyn_cast<StringInit>(I0))
997  if (const StringInit *I1s = dyn_cast<StringInit>(I1))
998  return ConcatStringInits(I0s, I1s);
999  return BinOpInit::get(BinOpInit::STRCONCAT, I0, I1,
1001 }
1002 
1004  const ListInit *RHS) {
1008  return ListInit::get(Args, LHS->getElementType());
1009 }
1010 
1012  assert(isa<ListRecTy>(LHS->getType()) && "First arg must be a list");
1013 
1014  // Shortcut for the common case of concatenating two lists.
1015  if (const ListInit *LHSList = dyn_cast<ListInit>(LHS))
1016  if (const ListInit *RHSList = dyn_cast<ListInit>(RHS))
1017  return ConcatListInits(LHSList, RHSList);
1019 }
1020 
1021 Init *BinOpInit::Fold(Record *CurRec) const {
1022  switch (getOpcode()) {
1023  case CONCAT: {
1024  DagInit *LHSs = dyn_cast<DagInit>(LHS);
1025  DagInit *RHSs = dyn_cast<DagInit>(RHS);
1026  if (LHSs && RHSs) {
1027  DefInit *LOp = dyn_cast<DefInit>(LHSs->getOperator());
1028  DefInit *ROp = dyn_cast<DefInit>(RHSs->getOperator());
1029  if ((!LOp && !isa<UnsetInit>(LHSs->getOperator())) ||
1030  (!ROp && !isa<UnsetInit>(RHSs->getOperator())))
1031  break;
1032  if (LOp && ROp && LOp->getDef() != ROp->getDef()) {
1033  PrintFatalError(Twine("Concatenated Dag operators do not match: '") +
1034  LHSs->getAsString() + "' vs. '" + RHSs->getAsString() +
1035  "'");
1036  }
1037  Init *Op = LOp ? LOp : ROp;
1038  if (!Op)
1040 
1042  SmallVector<StringInit*, 8> ArgNames;
1043  for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) {
1044  Args.push_back(LHSs->getArg(i));
1045  ArgNames.push_back(LHSs->getArgName(i));
1046  }
1047  for (unsigned i = 0, e = RHSs->getNumArgs(); i != e; ++i) {
1048  Args.push_back(RHSs->getArg(i));
1049  ArgNames.push_back(RHSs->getArgName(i));
1050  }
1051  return DagInit::get(Op, nullptr, Args, ArgNames);
1052  }
1053  break;
1054  }
1055  case LISTCONCAT: {
1056  ListInit *LHSs = dyn_cast<ListInit>(LHS);
1057  ListInit *RHSs = dyn_cast<ListInit>(RHS);
1058  if (LHSs && RHSs) {
1060  llvm::append_range(Args, *LHSs);
1061  llvm::append_range(Args, *RHSs);
1062  return ListInit::get(Args, LHSs->getElementType());
1063  }
1064  break;
1065  }
1066  case LISTSPLAT: {
1067  TypedInit *Value = dyn_cast<TypedInit>(LHS);
1068  IntInit *Size = dyn_cast<IntInit>(RHS);
1069  if (Value && Size) {
1070  SmallVector<Init *, 8> Args(Size->getValue(), Value);
1071  return ListInit::get(Args, Value->getType());
1072  }
1073  break;
1074  }
1075  case STRCONCAT: {
1076  StringInit *LHSs = dyn_cast<StringInit>(LHS);
1077  StringInit *RHSs = dyn_cast<StringInit>(RHS);
1078  if (LHSs && RHSs)
1079  return ConcatStringInits(LHSs, RHSs);
1080  break;
1081  }
1082  case INTERLEAVE: {
1083  ListInit *List = dyn_cast<ListInit>(LHS);
1084  StringInit *Delim = dyn_cast<StringInit>(RHS);
1085  if (List && Delim) {
1086  StringInit *Result;
1087  if (isa<StringRecTy>(List->getElementType()))
1088  Result = interleaveStringList(List, Delim);
1089  else
1090  Result = interleaveIntList(List, Delim);
1091  if (Result)
1092  return Result;
1093  }
1094  break;
1095  }
1096  case EQ:
1097  case NE:
1098  case LE:
1099  case LT:
1100  case GE:
1101  case GT: {
1102  // First see if we have two bit, bits, or int.
1103  IntInit *LHSi = dyn_cast_or_null<IntInit>(
1105  IntInit *RHSi = dyn_cast_or_null<IntInit>(
1107 
1108  if (LHSi && RHSi) {
1109  bool Result;
1110  switch (getOpcode()) {
1111  case EQ: Result = LHSi->getValue() == RHSi->getValue(); break;
1112  case NE: Result = LHSi->getValue() != RHSi->getValue(); break;
1113  case LE: Result = LHSi->getValue() <= RHSi->getValue(); break;
1114  case LT: Result = LHSi->getValue() < RHSi->getValue(); break;
1115  case GE: Result = LHSi->getValue() >= RHSi->getValue(); break;
1116  case GT: Result = LHSi->getValue() > RHSi->getValue(); break;
1117  default: llvm_unreachable("unhandled comparison");
1118  }
1119  return BitInit::get(getRecordKeeper(), Result);
1120  }
1121 
1122  // Next try strings.
1123  StringInit *LHSs = dyn_cast<StringInit>(LHS);
1124  StringInit *RHSs = dyn_cast<StringInit>(RHS);
1125 
1126  if (LHSs && RHSs) {
1127  bool Result;
1128  switch (getOpcode()) {
1129  case EQ: Result = LHSs->getValue() == RHSs->getValue(); break;
1130  case NE: Result = LHSs->getValue() != RHSs->getValue(); break;
1131  case LE: Result = LHSs->getValue() <= RHSs->getValue(); break;
1132  case LT: Result = LHSs->getValue() < RHSs->getValue(); break;
1133  case GE: Result = LHSs->getValue() >= RHSs->getValue(); break;
1134  case GT: Result = LHSs->getValue() > RHSs->getValue(); break;
1135  default: llvm_unreachable("unhandled comparison");
1136  }
1137  return BitInit::get(getRecordKeeper(), Result);
1138  }
1139 
1140  // Finally, !eq and !ne can be used with records.
1141  if (getOpcode() == EQ || getOpcode() == NE) {
1142  DefInit *LHSd = dyn_cast<DefInit>(LHS);
1143  DefInit *RHSd = dyn_cast<DefInit>(RHS);
1144  if (LHSd && RHSd)
1145  return BitInit::get(getRecordKeeper(),
1146  (getOpcode() == EQ) ? LHSd == RHSd : LHSd != RHSd);
1147  }
1148 
1149  break;
1150  }
1151  case SETDAGOP: {
1152  DagInit *Dag = dyn_cast<DagInit>(LHS);
1153  DefInit *Op = dyn_cast<DefInit>(RHS);
1154  if (Dag && Op) {
1156  SmallVector<StringInit*, 8> ArgNames;
1157  for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) {
1158  Args.push_back(Dag->getArg(i));
1159  ArgNames.push_back(Dag->getArgName(i));
1160  }
1161  return DagInit::get(Op, nullptr, Args, ArgNames);
1162  }
1163  break;
1164  }
1165  case ADD:
1166  case SUB:
1167  case MUL:
1168  case DIV:
1169  case AND:
1170  case OR:
1171  case XOR:
1172  case SHL:
1173  case SRA:
1174  case SRL: {
1175  IntInit *LHSi = dyn_cast_or_null<IntInit>(
1177  IntInit *RHSi = dyn_cast_or_null<IntInit>(
1179  if (LHSi && RHSi) {
1180  int64_t LHSv = LHSi->getValue(), RHSv = RHSi->getValue();
1181  int64_t Result;
1182  switch (getOpcode()) {
1183  default: llvm_unreachable("Bad opcode!");
1184  case ADD: Result = LHSv + RHSv; break;
1185  case SUB: Result = LHSv - RHSv; break;
1186  case MUL: Result = LHSv * RHSv; break;
1187  case DIV:
1188  if (RHSv == 0)
1189  PrintFatalError(CurRec->getLoc(),
1190  "Illegal operation: division by zero");
1191  else if (LHSv == INT64_MIN && RHSv == -1)
1192  PrintFatalError(CurRec->getLoc(),
1193  "Illegal operation: INT64_MIN / -1");
1194  else
1195  Result = LHSv / RHSv;
1196  break;
1197  case AND: Result = LHSv & RHSv; break;
1198  case OR: Result = LHSv | RHSv; break;
1199  case XOR: Result = LHSv ^ RHSv; break;
1200  case SHL: Result = (uint64_t)LHSv << (uint64_t)RHSv; break;
1201  case SRA: Result = LHSv >> RHSv; break;
1202  case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break;
1203  }
1204  return IntInit::get(getRecordKeeper(), Result);
1205  }
1206  break;
1207  }
1208  }
1209  return const_cast<BinOpInit *>(this);
1210 }
1211 
1213  Init *lhs = LHS->resolveReferences(R);
1214  Init *rhs = RHS->resolveReferences(R);
1215 
1216  if (LHS != lhs || RHS != rhs)
1217  return (BinOpInit::get(getOpcode(), lhs, rhs, getType()))
1218  ->Fold(R.getCurrentRecord());
1219  return const_cast<BinOpInit *>(this);
1220 }
1221 
1222 std::string BinOpInit::getAsString() const {
1223  std::string Result;
1224  switch (getOpcode()) {
1225  case CONCAT: Result = "!con"; break;
1226  case ADD: Result = "!add"; break;
1227  case SUB: Result = "!sub"; break;
1228  case MUL: Result = "!mul"; break;
1229  case DIV: Result = "!div"; break;
1230  case AND: Result = "!and"; break;
1231  case OR: Result = "!or"; break;
1232  case XOR: Result = "!xor"; break;
1233  case SHL: Result = "!shl"; break;
1234  case SRA: Result = "!sra"; break;
1235  case SRL: Result = "!srl"; break;
1236  case EQ: Result = "!eq"; break;
1237  case NE: Result = "!ne"; break;
1238  case LE: Result = "!le"; break;
1239  case LT: Result = "!lt"; break;
1240  case GE: Result = "!ge"; break;
1241  case GT: Result = "!gt"; break;
1242  case LISTCONCAT: Result = "!listconcat"; break;
1243  case LISTSPLAT: Result = "!listsplat"; break;
1244  case STRCONCAT: Result = "!strconcat"; break;
1245  case INTERLEAVE: Result = "!interleave"; break;
1246  case SETDAGOP: Result = "!setdagop"; break;
1247  }
1248  return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")";
1249 }
1250 
1251 static void
1252 ProfileTernOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *MHS,
1253  Init *RHS, RecTy *Type) {
1254  ID.AddInteger(Opcode);
1255  ID.AddPointer(LHS);
1256  ID.AddPointer(MHS);
1257  ID.AddPointer(RHS);
1258  ID.AddPointer(Type);
1259 }
1260 
1262  RecTy *Type) {
1264  ProfileTernOpInit(ID, Opc, LHS, MHS, RHS, Type);
1265 
1266  detail::RecordKeeperImpl &RK = LHS->getRecordKeeper().getImpl();
1267  void *IP = nullptr;
1268  if (TernOpInit *I = RK.TheTernOpInitPool.FindNodeOrInsertPos(ID, IP))
1269  return I;
1270 
1271  TernOpInit *I = new (RK.Allocator) TernOpInit(Opc, LHS, MHS, RHS, Type);
1272  RK.TheTernOpInitPool.InsertNode(I, IP);
1273  return I;
1274 }
1275 
1278 }
1279 
1280 static Init *ItemApply(Init *LHS, Init *MHSe, Init *RHS, Record *CurRec) {
1281  MapResolver R(CurRec);
1282  R.set(LHS, MHSe);
1283  return RHS->resolveReferences(R);
1284 }
1285 
1287  Record *CurRec) {
1288  bool Change = false;
1289  Init *Val = ItemApply(LHS, MHSd->getOperator(), RHS, CurRec);
1290  if (Val != MHSd->getOperator())
1291  Change = true;
1292 
1294  for (unsigned int i = 0; i < MHSd->getNumArgs(); ++i) {
1295  Init *Arg = MHSd->getArg(i);
1296  Init *NewArg;
1297  StringInit *ArgName = MHSd->getArgName(i);
1298 
1299  if (DagInit *Argd = dyn_cast<DagInit>(Arg))
1300  NewArg = ForeachDagApply(LHS, Argd, RHS, CurRec);
1301  else
1302  NewArg = ItemApply(LHS, Arg, RHS, CurRec);
1303 
1304  NewArgs.push_back(std::make_pair(NewArg, ArgName));
1305  if (Arg != NewArg)
1306  Change = true;
1307  }
1308 
1309  if (Change)
1310  return DagInit::get(Val, nullptr, NewArgs);
1311  return MHSd;
1312 }
1313 
1314 // Applies RHS to all elements of MHS, using LHS as a temp variable.
1316  Record *CurRec) {
1317  if (DagInit *MHSd = dyn_cast<DagInit>(MHS))
1318  return ForeachDagApply(LHS, MHSd, RHS, CurRec);
1319 
1320  if (ListInit *MHSl = dyn_cast<ListInit>(MHS)) {
1321  SmallVector<Init *, 8> NewList(MHSl->begin(), MHSl->end());
1322 
1323  for (Init *&Item : NewList) {
1324  Init *NewItem = ItemApply(LHS, Item, RHS, CurRec);
1325  if (NewItem != Item)
1326  Item = NewItem;
1327  }
1328  return ListInit::get(NewList, cast<ListRecTy>(Type)->getElementType());
1329  }
1330 
1331  return nullptr;
1332 }
1333 
1334 // Evaluates RHS for all elements of MHS, using LHS as a temp variable.
1335 // Creates a new list with the elements that evaluated to true.
1337  Record *CurRec) {
1338  if (ListInit *MHSl = dyn_cast<ListInit>(MHS)) {
1339  SmallVector<Init *, 8> NewList;
1340 
1341  for (Init *Item : MHSl->getValues()) {
1342  Init *Include = ItemApply(LHS, Item, RHS, CurRec);
1343  if (!Include)
1344  return nullptr;
1345  if (IntInit *IncludeInt =
1346  dyn_cast_or_null<IntInit>(Include->convertInitializerTo(
1347  IntRecTy::get(LHS->getRecordKeeper())))) {
1348  if (IncludeInt->getValue())
1349  NewList.push_back(Item);
1350  } else {
1351  return nullptr;
1352  }
1353  }
1354  return ListInit::get(NewList, cast<ListRecTy>(Type)->getElementType());
1355  }
1356 
1357  return nullptr;
1358 }
1359 
1360 Init *TernOpInit::Fold(Record *CurRec) const {
1361  RecordKeeper &RK = getRecordKeeper();
1362  switch (getOpcode()) {
1363  case SUBST: {
1364  DefInit *LHSd = dyn_cast<DefInit>(LHS);
1365  VarInit *LHSv = dyn_cast<VarInit>(LHS);
1366  StringInit *LHSs = dyn_cast<StringInit>(LHS);
1367 
1368  DefInit *MHSd = dyn_cast<DefInit>(MHS);
1369  VarInit *MHSv = dyn_cast<VarInit>(MHS);
1370  StringInit *MHSs = dyn_cast<StringInit>(MHS);
1371 
1372  DefInit *RHSd = dyn_cast<DefInit>(RHS);
1373  VarInit *RHSv = dyn_cast<VarInit>(RHS);
1374  StringInit *RHSs = dyn_cast<StringInit>(RHS);
1375 
1376  if (LHSd && MHSd && RHSd) {
1377  Record *Val = RHSd->getDef();
1378  if (LHSd->getAsString() == RHSd->getAsString())
1379  Val = MHSd->getDef();
1380  return DefInit::get(Val);
1381  }
1382  if (LHSv && MHSv && RHSv) {
1383  std::string Val = std::string(RHSv->getName());
1384  if (LHSv->getAsString() == RHSv->getAsString())
1385  Val = std::string(MHSv->getName());
1386  return VarInit::get(Val, getType());
1387  }
1388  if (LHSs && MHSs && RHSs) {
1389  std::string Val = std::string(RHSs->getValue());
1390 
1391  std::string::size_type found;
1392  std::string::size_type idx = 0;
1393  while (true) {
1394  found = Val.find(std::string(LHSs->getValue()), idx);
1395  if (found == std::string::npos)
1396  break;
1397  Val.replace(found, LHSs->getValue().size(),
1398  std::string(MHSs->getValue()));
1399  idx = found + MHSs->getValue().size();
1400  }
1401 
1402  return StringInit::get(RK, Val);
1403  }
1404  break;
1405  }
1406 
1407  case FOREACH: {
1408  if (Init *Result = ForeachHelper(LHS, MHS, RHS, getType(), CurRec))
1409  return Result;
1410  break;
1411  }
1412 
1413  case FILTER: {
1414  if (Init *Result = FilterHelper(LHS, MHS, RHS, getType(), CurRec))
1415  return Result;
1416  break;
1417  }
1418 
1419  case IF: {
1420  if (IntInit *LHSi = dyn_cast_or_null<IntInit>(
1421  LHS->convertInitializerTo(IntRecTy::get(RK)))) {
1422  if (LHSi->getValue())
1423  return MHS;
1424  return RHS;
1425  }
1426  break;
1427  }
1428 
1429  case DAG: {
1430  ListInit *MHSl = dyn_cast<ListInit>(MHS);
1431  ListInit *RHSl = dyn_cast<ListInit>(RHS);
1432  bool MHSok = MHSl || isa<UnsetInit>(MHS);
1433  bool RHSok = RHSl || isa<UnsetInit>(RHS);
1434 
1435  if (isa<UnsetInit>(MHS) && isa<UnsetInit>(RHS))
1436  break; // Typically prevented by the parser, but might happen with template args
1437 
1438  if (MHSok && RHSok && (!MHSl || !RHSl || MHSl->size() == RHSl->size())) {
1440  unsigned Size = MHSl ? MHSl->size() : RHSl->size();
1441  for (unsigned i = 0; i != Size; ++i) {
1442  Init *Node = MHSl ? MHSl->getElement(i) : UnsetInit::get(RK);
1443  Init *Name = RHSl ? RHSl->getElement(i) : UnsetInit::get(RK);
1444  if (!isa<StringInit>(Name) && !isa<UnsetInit>(Name))
1445  return const_cast<TernOpInit *>(this);
1446  Children.emplace_back(Node, dyn_cast<StringInit>(Name));
1447  }
1448  return DagInit::get(LHS, nullptr, Children);
1449  }
1450  break;
1451  }
1452 
1453  case SUBSTR: {
1454  StringInit *LHSs = dyn_cast<StringInit>(LHS);
1455  IntInit *MHSi = dyn_cast<IntInit>(MHS);
1456  IntInit *RHSi = dyn_cast<IntInit>(RHS);
1457  if (LHSs && MHSi && RHSi) {
1458  int64_t StringSize = LHSs->getValue().size();
1459  int64_t Start = MHSi->getValue();
1460  int64_t Length = RHSi->getValue();
1461  if (Start < 0 || Start > StringSize)
1462  PrintError(CurRec->getLoc(),
1463  Twine("!substr start position is out of range 0...") +
1464  std::to_string(StringSize) + ": " +
1465  std::to_string(Start));
1466  if (Length < 0)
1467  PrintError(CurRec->getLoc(), "!substr length must be nonnegative");
1468  return StringInit::get(RK, LHSs->getValue().substr(Start, Length),
1469  LHSs->getFormat());
1470  }
1471  break;
1472  }
1473 
1474  case FIND: {
1475  StringInit *LHSs = dyn_cast<StringInit>(LHS);
1476  StringInit *MHSs = dyn_cast<StringInit>(MHS);
1477  IntInit *RHSi = dyn_cast<IntInit>(RHS);
1478  if (LHSs && MHSs && RHSi) {
1479  int64_t SourceSize = LHSs->getValue().size();
1480  int64_t Start = RHSi->getValue();
1481  if (Start < 0 || Start > SourceSize)
1482  PrintError(CurRec->getLoc(),
1483  Twine("!find start position is out of range 0...") +
1484  std::to_string(SourceSize) + ": " +
1485  std::to_string(Start));
1486  auto I = LHSs->getValue().find(MHSs->getValue(), Start);
1487  if (I == std::string::npos)
1488  return IntInit::get(RK, -1);
1489  return IntInit::get(RK, I);
1490  }
1491  break;
1492  }
1493  }
1494 
1495  return const_cast<TernOpInit *>(this);
1496 }
1497 
1499  Init *lhs = LHS->resolveReferences(R);
1500 
1501  if (getOpcode() == IF && lhs != LHS) {
1502  if (IntInit *Value = dyn_cast_or_null<IntInit>(
1504  // Short-circuit
1505  if (Value->getValue())
1506  return MHS->resolveReferences(R);
1507  return RHS->resolveReferences(R);
1508  }
1509  }
1510 
1511  Init *mhs = MHS->resolveReferences(R);
1512  Init *rhs;
1513 
1514  if (getOpcode() == FOREACH || getOpcode() == FILTER) {
1515  ShadowResolver SR(R);
1516  SR.addShadow(lhs);
1517  rhs = RHS->resolveReferences(SR);
1518  } else {
1519  rhs = RHS->resolveReferences(R);
1520  }
1521 
1522  if (LHS != lhs || MHS != mhs || RHS != rhs)
1523  return (TernOpInit::get(getOpcode(), lhs, mhs, rhs, getType()))
1524  ->Fold(R.getCurrentRecord());
1525  return const_cast<TernOpInit *>(this);
1526 }
1527 
1528 std::string TernOpInit::getAsString() const {
1529  std::string Result;
1530  bool UnquotedLHS = false;
1531  switch (getOpcode()) {
1532  case DAG: Result = "!dag"; break;
1533  case FILTER: Result = "!filter"; UnquotedLHS = true; break;
1534  case FOREACH: Result = "!foreach"; UnquotedLHS = true; break;
1535  case IF: Result = "!if"; break;
1536  case SUBST: Result = "!subst"; break;
1537  case SUBSTR: Result = "!substr"; break;
1538  case FIND: Result = "!find"; break;
1539  }
1540  return (Result + "(" +
1541  (UnquotedLHS ? LHS->getAsUnquotedString() : LHS->getAsString()) +
1542  ", " + MHS->getAsString() + ", " + RHS->getAsString() + ")");
1543 }
1544 
1545 static void ProfileFoldOpInit(FoldingSetNodeID &ID, Init *Start, Init *List,
1546  Init *A, Init *B, Init *Expr, RecTy *Type) {
1547  ID.AddPointer(Start);
1548  ID.AddPointer(List);
1549  ID.AddPointer(A);
1550  ID.AddPointer(B);
1551  ID.AddPointer(Expr);
1552  ID.AddPointer(Type);
1553 }
1554 
1556  Init *Expr, RecTy *Type) {
1558  ProfileFoldOpInit(ID, Start, List, A, B, Expr, Type);
1559 
1560  detail::RecordKeeperImpl &RK = Start->getRecordKeeper().getImpl();
1561  void *IP = nullptr;
1562  if (FoldOpInit *I = RK.TheFoldOpInitPool.FindNodeOrInsertPos(ID, IP))
1563  return I;
1564 
1565  FoldOpInit *I = new (RK.Allocator) FoldOpInit(Start, List, A, B, Expr, Type);
1566  RK.TheFoldOpInitPool.InsertNode(I, IP);
1567  return I;
1568 }
1569 
1571  ProfileFoldOpInit(ID, Start, List, A, B, Expr, getType());
1572 }
1573 
1574 Init *FoldOpInit::Fold(Record *CurRec) const {
1575  if (ListInit *LI = dyn_cast<ListInit>(List)) {
1576  Init *Accum = Start;
1577  for (Init *Elt : *LI) {
1578  MapResolver R(CurRec);
1579  R.set(A, Accum);
1580  R.set(B, Elt);
1581  Accum = Expr->resolveReferences(R);
1582  }
1583  return Accum;
1584  }
1585  return const_cast<FoldOpInit *>(this);
1586 }
1587 
1589  Init *NewStart = Start->resolveReferences(R);
1590  Init *NewList = List->resolveReferences(R);
1591  ShadowResolver SR(R);
1592  SR.addShadow(A);
1593  SR.addShadow(B);
1594  Init *NewExpr = Expr->resolveReferences(SR);
1595 
1596  if (Start == NewStart && List == NewList && Expr == NewExpr)
1597  return const_cast<FoldOpInit *>(this);
1598 
1599  return get(NewStart, NewList, A, B, NewExpr, getType())
1600  ->Fold(R.getCurrentRecord());
1601 }
1602 
1603 Init *FoldOpInit::getBit(unsigned Bit) const {
1604  return VarBitInit::get(const_cast<FoldOpInit *>(this), Bit);
1605 }
1606 
1607 std::string FoldOpInit::getAsString() const {
1608  return (Twine("!foldl(") + Start->getAsString() + ", " + List->getAsString() +
1609  ", " + A->getAsUnquotedString() + ", " + B->getAsUnquotedString() +
1610  ", " + Expr->getAsString() + ")")
1611  .str();
1612 }
1613 
1615  Init *Expr) {
1616  ID.AddPointer(CheckType);
1617  ID.AddPointer(Expr);
1618 }
1619 
1621 
1623  ProfileIsAOpInit(ID, CheckType, Expr);
1624 
1626  void *IP = nullptr;
1627  if (IsAOpInit *I = RK.TheIsAOpInitPool.FindNodeOrInsertPos(ID, IP))
1628  return I;
1629 
1630  IsAOpInit *I = new (RK.Allocator) IsAOpInit(CheckType, Expr);
1631  RK.TheIsAOpInitPool.InsertNode(I, IP);
1632  return I;
1633 }
1634 
1636  ProfileIsAOpInit(ID, CheckType, Expr);
1637 }
1638 
1640  if (TypedInit *TI = dyn_cast<TypedInit>(Expr)) {
1641  // Is the expression type known to be (a subclass of) the desired type?
1642  if (TI->getType()->typeIsConvertibleTo(CheckType))
1643  return IntInit::get(getRecordKeeper(), 1);
1644 
1645  if (isa<RecordRecTy>(CheckType)) {
1646  // If the target type is not a subclass of the expression type, or if
1647  // the expression has fully resolved to a record, we know that it can't
1648  // be of the required type.
1649  if (!CheckType->typeIsConvertibleTo(TI->getType()) || isa<DefInit>(Expr))
1650  return IntInit::get(getRecordKeeper(), 0);
1651  } else {
1652  // We treat non-record types as not castable.
1653  return IntInit::get(getRecordKeeper(), 0);
1654  }
1655  }
1656  return const_cast<IsAOpInit *>(this);
1657 }
1658 
1660  Init *NewExpr = Expr->resolveReferences(R);
1661  if (Expr != NewExpr)
1662  return get(CheckType, NewExpr)->Fold();
1663  return const_cast<IsAOpInit *>(this);
1664 }
1665 
1666 Init *IsAOpInit::getBit(unsigned Bit) const {
1667  return VarBitInit::get(const_cast<IsAOpInit *>(this), Bit);
1668 }
1669 
1670 std::string IsAOpInit::getAsString() const {
1671  return (Twine("!isa<") + CheckType->getAsString() + ">(" +
1672  Expr->getAsString() + ")")
1673  .str();
1674 }
1675 
1677  Init *Expr) {
1678  ID.AddPointer(CheckType);
1679  ID.AddPointer(Expr);
1680 }
1681 
1684  ProfileExistsOpInit(ID, CheckType, Expr);
1685 
1687  void *IP = nullptr;
1688  if (ExistsOpInit *I = RK.TheExistsOpInitPool.FindNodeOrInsertPos(ID, IP))
1689  return I;
1690 
1691  ExistsOpInit *I = new (RK.Allocator) ExistsOpInit(CheckType, Expr);
1692  RK.TheExistsOpInitPool.InsertNode(I, IP);
1693  return I;
1694 }
1695 
1697  ProfileExistsOpInit(ID, CheckType, Expr);
1698 }
1699 
1700 Init *ExistsOpInit::Fold(Record *CurRec, bool IsFinal) const {
1701  if (StringInit *Name = dyn_cast<StringInit>(Expr)) {
1702  if (!CurRec && !IsFinal)
1703  return const_cast<ExistsOpInit *>(this);
1704 
1705  // Self-references are allowed, but their resolution is delayed until
1706  // the final resolve to ensure that we get the correct type for them.
1707  auto *Anonymous = dyn_cast<AnonymousNameInit>(CurRec->getNameInit());
1708  if (Name == CurRec->getNameInit() ||
1709  (Anonymous && Name == Anonymous->getNameInit())) {
1710  if (!IsFinal)
1711  return const_cast<ExistsOpInit *>(this);
1712 
1713  // No doubt that there exists a record, so we should check if types are
1714  // compatiable.
1715  return IntInit::get(getRecordKeeper(),
1716  CurRec->getType()->typeIsA(CheckType));
1717  }
1718 
1719  // Look up all defined records to see if we can find one.
1720  Record *D = CheckType->getRecordKeeper().getDef(Name->getValue());
1721  if (!D) {
1722  if (IsFinal)
1723  return IntInit::get(getRecordKeeper(), 0);
1724  return const_cast<ExistsOpInit *>(this);
1725  }
1726 
1727  // Check if types are compatiable.
1728  return IntInit::get(getRecordKeeper(),
1729  DefInit::get(D)->getType()->typeIsA(CheckType));
1730  }
1731  return const_cast<ExistsOpInit *>(this);
1732 }
1733 
1735  Init *NewExpr = Expr->resolveReferences(R);
1736  if (Expr != NewExpr || R.isFinal())
1737  return get(CheckType, NewExpr)->Fold(R.getCurrentRecord(), R.isFinal());
1738  return const_cast<ExistsOpInit *>(this);
1739 }
1740 
1741 Init *ExistsOpInit::getBit(unsigned Bit) const {
1742  return VarBitInit::get(const_cast<ExistsOpInit *>(this), Bit);
1743 }
1744 
1745 std::string ExistsOpInit::getAsString() const {
1746  return (Twine("!exists<") + CheckType->getAsString() + ">(" +
1747  Expr->getAsString() + ")")
1748  .str();
1749 }
1750 
1752  if (RecordRecTy *RecordType = dyn_cast<RecordRecTy>(getType())) {
1753  for (Record *Rec : RecordType->getClasses()) {
1754  if (RecordVal *Field = Rec->getValue(FieldName))
1755  return Field->getType();
1756  }
1757  }
1758  return nullptr;
1759 }
1760 
1761 Init *
1763  if (getType() == Ty || getType()->typeIsA(Ty))
1764  return const_cast<TypedInit *>(this);
1765 
1766  if (isa<BitRecTy>(getType()) && isa<BitsRecTy>(Ty) &&
1767  cast<BitsRecTy>(Ty)->getNumBits() == 1)
1768  return BitsInit::get(getRecordKeeper(), {const_cast<TypedInit *>(this)});
1769 
1770  return nullptr;
1771 }
1772 
1774  BitsRecTy *T = dyn_cast<BitsRecTy>(getType());
1775  if (!T) return nullptr; // Cannot subscript a non-bits variable.
1776  unsigned NumBits = T->getNumBits();
1777 
1778  SmallVector<Init *, 16> NewBits;
1779  NewBits.reserve(Bits.size());
1780  for (unsigned Bit : Bits) {
1781  if (Bit >= NumBits)
1782  return nullptr;
1783 
1784  NewBits.push_back(VarBitInit::get(const_cast<TypedInit *>(this), Bit));
1785  }
1786  return BitsInit::get(getRecordKeeper(), NewBits);
1787 }
1788 
1790  // Handle the common case quickly
1791  if (getType() == Ty || getType()->typeIsA(Ty))
1792  return const_cast<TypedInit *>(this);
1793 
1794  if (Init *Converted = convertInitializerTo(Ty)) {
1795  assert(!isa<TypedInit>(Converted) ||
1796  cast<TypedInit>(Converted)->getType()->typeIsA(Ty));
1797  return Converted;
1798  }
1799 
1800  if (!getType()->typeIsConvertibleTo(Ty))
1801  return nullptr;
1802 
1803  return UnOpInit::get(UnOpInit::CAST, const_cast<TypedInit *>(this), Ty)
1804  ->Fold(nullptr);
1805 }
1806 
1808  ListRecTy *T = dyn_cast<ListRecTy>(getType());
1809  if (!T) return nullptr; // Cannot subscript a non-list variable.
1810 
1811  if (Elements.size() == 1)
1812  return VarListElementInit::get(const_cast<TypedInit *>(this), Elements[0]);
1813 
1814  SmallVector<Init*, 8> ListInits;
1815  ListInits.reserve(Elements.size());
1816  for (unsigned Element : Elements)
1817  ListInits.push_back(VarListElementInit::get(const_cast<TypedInit *>(this),
1818  Element));
1819  return ListInit::get(ListInits, T->getElementType());
1820 }
1821 
1822 
1824  Init *Value = StringInit::get(T->getRecordKeeper(), VN);
1825  return VarInit::get(Value, T);
1826 }
1827 
1829  detail::RecordKeeperImpl &RK = T->getRecordKeeper().getImpl();
1830  VarInit *&I = RK.TheVarInitPool[std::make_pair(T, VN)];
1831  if (!I)
1832  I = new (RK.Allocator) VarInit(VN, T);
1833  return I;
1834 }
1835 
1837  StringInit *NameString = cast<StringInit>(getNameInit());
1838  return NameString->getValue();
1839 }
1840 
1841 Init *VarInit::getBit(unsigned Bit) const {
1843  return const_cast<VarInit*>(this);
1844  return VarBitInit::get(const_cast<VarInit*>(this), Bit);
1845 }
1846 
1848  if (Init *Val = R.resolve(VarName))
1849  return Val;
1850  return const_cast<VarInit *>(this);
1851 }
1852 
1854  detail::RecordKeeperImpl &RK = T->getRecordKeeper().getImpl();
1855  VarBitInit *&I = RK.TheVarBitInitPool[std::make_pair(T, B)];
1856  if (!I)
1857  I = new (RK.Allocator) VarBitInit(T, B);
1858  return I;
1859 }
1860 
1861 std::string VarBitInit::getAsString() const {
1862  return TI->getAsString() + "{" + utostr(Bit) + "}";
1863 }
1864 
1866  Init *I = TI->resolveReferences(R);
1867  if (TI != I)
1868  return I->getBit(getBitNum());
1869 
1870  return const_cast<VarBitInit*>(this);
1871 }
1872 
1874  detail::RecordKeeperImpl &RK = T->getRecordKeeper().getImpl();
1875  VarListElementInit *&I = RK.TheVarListElementInitPool[std::make_pair(T, E)];
1876  if (!I)
1877  I = new (RK.Allocator) VarListElementInit(T, E);
1878  return I;
1879 }
1880 
1881 std::string VarListElementInit::getAsString() const {
1882  return TI->getAsString() + "[" + utostr(Element) + "]";
1883 }
1884 
1886  Init *NewTI = TI->resolveReferences(R);
1887  if (ListInit *List = dyn_cast<ListInit>(NewTI)) {
1888  // Leave out-of-bounds array references as-is. This can happen without
1889  // being an error, e.g. in the untaken "branch" of an !if expression.
1890  if (getElementNum() < List->size())
1891  return List->getElement(getElementNum());
1892  }
1893  if (NewTI != TI && isa<TypedInit>(NewTI))
1894  return VarListElementInit::get(cast<TypedInit>(NewTI), getElementNum());
1895  return const_cast<VarListElementInit *>(this);
1896 }
1897 
1900  return const_cast<VarListElementInit*>(this);
1901  return VarBitInit::get(const_cast<VarListElementInit*>(this), Bit);
1902 }
1903 
1904 DefInit::DefInit(Record *D)
1905  : TypedInit(IK_DefInit, D->getType()), Def(D) {}
1906 
1908  return R->getDefInit();
1909 }
1910 
1912  if (auto *RRT = dyn_cast<RecordRecTy>(Ty))
1913  if (getType()->typeIsConvertibleTo(RRT))
1914  return const_cast<DefInit *>(this);
1915  return nullptr;
1916 }
1917 
1919  if (const RecordVal *RV = Def->getValue(FieldName))
1920  return RV->getType();
1921  return nullptr;
1922 }
1923 
1924 std::string DefInit::getAsString() const { return std::string(Def->getName()); }
1925 
1927  Record *Class,
1929  ID.AddInteger(Args.size());
1930  ID.AddPointer(Class);
1931 
1932  for (Init *I : Args)
1933  ID.AddPointer(I);
1934 }
1935 
1936 VarDefInit::VarDefInit(Record *Class, unsigned N)
1937  : TypedInit(IK_VarDefInit, RecordRecTy::get(Class)), Class(Class),
1938  NumArgs(N) {}
1939 
1942  ProfileVarDefInit(ID, Class, Args);
1943 
1944  detail::RecordKeeperImpl &RK = Class->getRecords().getImpl();
1945  void *IP = nullptr;
1946  if (VarDefInit *I = RK.TheVarDefInitPool.FindNodeOrInsertPos(ID, IP))
1947  return I;
1948 
1949  void *Mem = RK.Allocator.Allocate(totalSizeToAlloc<Init *>(Args.size()),
1950  alignof(VarDefInit));
1951  VarDefInit *I = new (Mem) VarDefInit(Class, Args.size());
1952  std::uninitialized_copy(Args.begin(), Args.end(),
1953  I->getTrailingObjects<Init *>());
1954  RK.TheVarDefInitPool.InsertNode(I, IP);
1955  return I;
1956 }
1957 
1959  ProfileVarDefInit(ID, Class, args());
1960 }
1961 
1962 DefInit *VarDefInit::instantiate() {
1963  if (!Def) {
1964  RecordKeeper &Records = Class->getRecords();
1965  auto NewRecOwner = std::make_unique<Record>(Records.getNewAnonymousName(),
1966  Class->getLoc(), Records,
1967  /*IsAnonymous=*/true);
1968  Record *NewRec = NewRecOwner.get();
1969 
1970  // Copy values from class to instance
1971  for (const RecordVal &Val : Class->getValues())
1972  NewRec->addValue(Val);
1973 
1974  // Copy assertions from class to instance.
1975  NewRec->appendAssertions(Class);
1976 
1977  // Substitute and resolve template arguments
1978  ArrayRef<Init *> TArgs = Class->getTemplateArgs();
1979  MapResolver R(NewRec);
1980 
1981  for (unsigned i = 0, e = TArgs.size(); i != e; ++i) {
1982  if (i < args_size())
1983  R.set(TArgs[i], getArg(i));
1984  else
1985  R.set(TArgs[i], NewRec->getValue(TArgs[i])->getValue());
1986 
1987  NewRec->removeValue(TArgs[i]);
1988  }
1989 
1990  NewRec->resolveReferences(R);
1991 
1992  // Add superclasses.
1994  for (const auto &SCPair : SCs)
1995  NewRec->addSuperClass(SCPair.first, SCPair.second);
1996 
1997  NewRec->addSuperClass(Class,
1998  SMRange(Class->getLoc().back(),
1999  Class->getLoc().back()));
2000 
2001  // Resolve internal references and store in record keeper
2002  NewRec->resolveReferences();
2003  Records.addDef(std::move(NewRecOwner));
2004 
2005  // Check the assertions.
2006  NewRec->checkRecordAssertions();
2007 
2008  Def = DefInit::get(NewRec);
2009  }
2010 
2011  return Def;
2012 }
2013 
2015  TrackUnresolvedResolver UR(&R);
2016  bool Changed = false;
2017  SmallVector<Init *, 8> NewArgs;
2018  NewArgs.reserve(args_size());
2019 
2020  for (Init *Arg : args()) {
2021  Init *NewArg = Arg->resolveReferences(UR);
2022  NewArgs.push_back(NewArg);
2023  Changed |= NewArg != Arg;
2024  }
2025 
2026  if (Changed) {
2027  auto New = VarDefInit::get(Class, NewArgs);
2028  if (!UR.foundUnresolved())
2029  return New->instantiate();
2030  return New;
2031  }
2032  return const_cast<VarDefInit *>(this);
2033 }
2034 
2036  if (Def)
2037  return Def;
2038 
2040  for (Init *Arg : args())
2041  Arg->resolveReferences(R);
2042 
2043  if (!R.foundUnresolved())
2044  return const_cast<VarDefInit *>(this)->instantiate();
2045  return const_cast<VarDefInit *>(this);
2046 }
2047 
2048 std::string VarDefInit::getAsString() const {
2049  std::string Result = Class->getNameInitAsString() + "<";
2050  const char *sep = "";
2051  for (Init *Arg : args()) {
2052  Result += sep;
2053  sep = ", ";
2054  Result += Arg->getAsString();
2055  }
2056  return Result + ">";
2057 }
2058 
2060  detail::RecordKeeperImpl &RK = R->getRecordKeeper().getImpl();
2061  FieldInit *&I = RK.TheFieldInitPool[std::make_pair(R, FN)];
2062  if (!I)
2063  I = new (RK.Allocator) FieldInit(R, FN);
2064  return I;
2065 }
2066 
2067 Init *FieldInit::getBit(unsigned Bit) const {
2069  return const_cast<FieldInit*>(this);
2070  return VarBitInit::get(const_cast<FieldInit*>(this), Bit);
2071 }
2072 
2074  Init *NewRec = Rec->resolveReferences(R);
2075  if (NewRec != Rec)
2076  return FieldInit::get(NewRec, FieldName)->Fold(R.getCurrentRecord());
2077  return const_cast<FieldInit *>(this);
2078 }
2079 
2080 Init *FieldInit::Fold(Record *CurRec) const {
2081  if (DefInit *DI = dyn_cast<DefInit>(Rec)) {
2082  Record *Def = DI->getDef();
2083  if (Def == CurRec)
2084  PrintFatalError(CurRec->getLoc(),
2085  Twine("Attempting to access field '") +
2086  FieldName->getAsUnquotedString() + "' of '" +
2087  Rec->getAsString() + "' is a forbidden self-reference");
2088  Init *FieldVal = Def->getValue(FieldName)->getValue();
2089  if (FieldVal->isConcrete())
2090  return FieldVal;
2091  }
2092  return const_cast<FieldInit *>(this);
2093 }
2094 
2096  if (DefInit *DI = dyn_cast<DefInit>(Rec)) {
2097  Init *FieldVal = DI->getDef()->getValue(FieldName)->getValue();
2098  return FieldVal->isConcrete();
2099  }
2100  return false;
2101 }
2102 
2104  ArrayRef<Init *> CondRange,
2105  ArrayRef<Init *> ValRange,
2106  const RecTy *ValType) {
2107  assert(CondRange.size() == ValRange.size() &&
2108  "Number of conditions and values must match!");
2109  ID.AddPointer(ValType);
2110  ArrayRef<Init *>::iterator Case = CondRange.begin();
2111  ArrayRef<Init *>::iterator Val = ValRange.begin();
2112 
2113  while (Case != CondRange.end()) {
2114  ID.AddPointer(*Case++);
2115  ID.AddPointer(*Val++);
2116  }
2117 }
2118 
2121  makeArrayRef(getTrailingObjects<Init *>(), NumConds),
2122  makeArrayRef(getTrailingObjects<Init *>() + NumConds, NumConds),
2123  ValType);
2124 }
2125 
2127  ArrayRef<Init *> ValRange, RecTy *Ty) {
2128  assert(CondRange.size() == ValRange.size() &&
2129  "Number of conditions and values must match!");
2130 
2132  ProfileCondOpInit(ID, CondRange, ValRange, Ty);
2133 
2135  void *IP = nullptr;
2136  if (CondOpInit *I = RK.TheCondOpInitPool.FindNodeOrInsertPos(ID, IP))
2137  return I;
2138 
2139  void *Mem = RK.Allocator.Allocate(
2140  totalSizeToAlloc<Init *>(2 * CondRange.size()), alignof(BitsInit));
2141  CondOpInit *I = new(Mem) CondOpInit(CondRange.size(), Ty);
2142 
2143  std::uninitialized_copy(CondRange.begin(), CondRange.end(),
2144  I->getTrailingObjects<Init *>());
2145  std::uninitialized_copy(ValRange.begin(), ValRange.end(),
2146  I->getTrailingObjects<Init *>()+CondRange.size());
2147  RK.TheCondOpInitPool.InsertNode(I, IP);
2148  return I;
2149 }
2150 
2152  SmallVector<Init*, 4> NewConds;
2153  bool Changed = false;
2154  for (const Init *Case : getConds()) {
2155  Init *NewCase = Case->resolveReferences(R);
2156  NewConds.push_back(NewCase);
2157  Changed |= NewCase != Case;
2158  }
2159 
2160  SmallVector<Init*, 4> NewVals;
2161  for (const Init *Val : getVals()) {
2162  Init *NewVal = Val->resolveReferences(R);
2163  NewVals.push_back(NewVal);
2164  Changed |= NewVal != Val;
2165  }
2166 
2167  if (Changed)
2168  return (CondOpInit::get(NewConds, NewVals,
2169  getValType()))->Fold(R.getCurrentRecord());
2170 
2171  return const_cast<CondOpInit *>(this);
2172 }
2173 
2174 Init *CondOpInit::Fold(Record *CurRec) const {
2175  RecordKeeper &RK = getRecordKeeper();
2176  for ( unsigned i = 0; i < NumConds; ++i) {
2177  Init *Cond = getCond(i);
2178  Init *Val = getVal(i);
2179 
2180  if (IntInit *CondI = dyn_cast_or_null<IntInit>(
2181  Cond->convertInitializerTo(IntRecTy::get(RK)))) {
2182  if (CondI->getValue())
2183  return Val->convertInitializerTo(getValType());
2184  } else {
2185  return const_cast<CondOpInit *>(this);
2186  }
2187  }
2188 
2189  PrintFatalError(CurRec->getLoc(),
2190  CurRec->getName() +
2191  " does not have any true condition in:" +
2192  this->getAsString());
2193  return nullptr;
2194 }
2195 
2197  for (const Init *Case : getConds())
2198  if (!Case->isConcrete())
2199  return false;
2200 
2201  for (const Init *Val : getVals())
2202  if (!Val->isConcrete())
2203  return false;
2204 
2205  return true;
2206 }
2207 
2209  for (const Init *Case : getConds())
2210  if (!Case->isComplete())
2211  return false;
2212 
2213  for (const Init *Val : getVals())
2214  if (!Val->isConcrete())
2215  return false;
2216 
2217  return true;
2218 }
2219 
2220 std::string CondOpInit::getAsString() const {
2221  std::string Result = "!cond(";
2222  for (unsigned i = 0; i < getNumConds(); i++) {
2223  Result += getCond(i)->getAsString() + ": ";
2224  Result += getVal(i)->getAsString();
2225  if (i != getNumConds()-1)
2226  Result += ", ";
2227  }
2228  return Result + ")";
2229 }
2230 
2231 Init *CondOpInit::getBit(unsigned Bit) const {
2232  return VarBitInit::get(const_cast<CondOpInit *>(this), Bit);
2233 }
2234 
2236  ArrayRef<Init *> ArgRange,
2237  ArrayRef<StringInit *> NameRange) {
2238  ID.AddPointer(V);
2239  ID.AddPointer(VN);
2240 
2241  ArrayRef<Init *>::iterator Arg = ArgRange.begin();
2243  while (Arg != ArgRange.end()) {
2244  assert(Name != NameRange.end() && "Arg name underflow!");
2245  ID.AddPointer(*Arg++);
2246  ID.AddPointer(*Name++);
2247  }
2248  assert(Name == NameRange.end() && "Arg name overflow!");
2249 }
2250 
2252  ArrayRef<StringInit *> NameRange) {
2253  assert(ArgRange.size() == NameRange.size());
2255  ProfileDagInit(ID, V, VN, ArgRange, NameRange);
2256 
2258  void *IP = nullptr;
2259  if (DagInit *I = RK.TheDagInitPool.FindNodeOrInsertPos(ID, IP))
2260  return I;
2261 
2262  void *Mem = RK.Allocator.Allocate(
2263  totalSizeToAlloc<Init *, StringInit *>(ArgRange.size(), NameRange.size()),
2264  alignof(BitsInit));
2265  DagInit *I = new (Mem) DagInit(V, VN, ArgRange.size(), NameRange.size());
2266  std::uninitialized_copy(ArgRange.begin(), ArgRange.end(),
2267  I->getTrailingObjects<Init *>());
2268  std::uninitialized_copy(NameRange.begin(), NameRange.end(),
2269  I->getTrailingObjects<StringInit *>());
2270  RK.TheDagInitPool.InsertNode(I, IP);
2271  return I;
2272 }
2273 
2274 DagInit *
2276  ArrayRef<std::pair<Init*, StringInit*>> args) {
2279 
2280  for (const auto &Arg : args) {
2281  Args.push_back(Arg.first);
2282  Names.push_back(Arg.second);
2283  }
2284 
2285  return DagInit::get(V, VN, Args, Names);
2286 }
2287 
2289  ProfileDagInit(ID, Val, ValName, makeArrayRef(getTrailingObjects<Init *>(), NumArgs), makeArrayRef(getTrailingObjects<StringInit *>(), NumArgNames));
2290 }
2291 
2293  if (DefInit *DefI = dyn_cast<DefInit>(Val))
2294  return DefI->getDef();
2295  PrintFatalError(Loc, "Expected record as operator");
2296  return nullptr;
2297 }
2298 
2300  SmallVector<Init*, 8> NewArgs;
2301  NewArgs.reserve(arg_size());
2302  bool ArgsChanged = false;
2303  for (const Init *Arg : getArgs()) {
2304  Init *NewArg = Arg->resolveReferences(R);
2305  NewArgs.push_back(NewArg);
2306  ArgsChanged |= NewArg != Arg;
2307  }
2308 
2309  Init *Op = Val->resolveReferences(R);
2310  if (Op != Val || ArgsChanged)
2311  return DagInit::get(Op, ValName, NewArgs, getArgNames());
2312 
2313  return const_cast<DagInit *>(this);
2314 }
2315 
2316 bool DagInit::isConcrete() const {
2317  if (!Val->isConcrete())
2318  return false;
2319  for (const Init *Elt : getArgs()) {
2320  if (!Elt->isConcrete())
2321  return false;
2322  }
2323  return true;
2324 }
2325 
2326 std::string DagInit::getAsString() const {
2327  std::string Result = "(" + Val->getAsString();
2328  if (ValName)
2329  Result += ":" + ValName->getAsUnquotedString();
2330  if (!arg_empty()) {
2331  Result += " " + getArg(0)->getAsString();
2332  if (getArgName(0)) Result += ":$" + getArgName(0)->getAsUnquotedString();
2333  for (unsigned i = 1, e = getNumArgs(); i != e; ++i) {
2334  Result += ", " + getArg(i)->getAsString();
2335  if (getArgName(i)) Result += ":$" + getArgName(i)->getAsUnquotedString();
2336  }
2337  }
2338  return Result + ")";
2339 }
2340 
2341 //===----------------------------------------------------------------------===//
2342 // Other implementations
2343 //===----------------------------------------------------------------------===//
2344 
2346  : Name(N), TyAndKind(T, K) {
2347  setValue(UnsetInit::get(N->getRecordKeeper()));
2348  assert(Value && "Cannot create unset value for current type!");
2349 }
2350 
2351 // This constructor accepts the same arguments as the above, but also
2352 // a source location.
2354  : Name(N), Loc(Loc), TyAndKind(T, K) {
2355  setValue(UnsetInit::get(N->getRecordKeeper()));
2356  assert(Value && "Cannot create unset value for current type!");
2357 }
2358 
2360  return cast<StringInit>(getNameInit())->getValue();
2361 }
2362 
2363 std::string RecordVal::getPrintType() const {
2365  if (auto *StrInit = dyn_cast<StringInit>(Value)) {
2366  if (StrInit->hasCodeFormat())
2367  return "code";
2368  else
2369  return "string";
2370  } else {
2371  return "string";
2372  }
2373  } else {
2374  return TyAndKind.getPointer()->getAsString();
2375  }
2376 }
2377 
2379  if (V) {
2380  Value = V->getCastTo(getType());
2381  if (Value) {
2382  assert(!isa<TypedInit>(Value) ||
2383  cast<TypedInit>(Value)->getType()->typeIsA(getType()));
2384  if (BitsRecTy *BTy = dyn_cast<BitsRecTy>(getType())) {
2385  if (!isa<BitsInit>(Value)) {
2387  Bits.reserve(BTy->getNumBits());
2388  for (unsigned I = 0, E = BTy->getNumBits(); I < E; ++I)
2389  Bits.push_back(Value->getBit(I));
2391  }
2392  }
2393  }
2394  return Value == nullptr;
2395  }
2396  Value = nullptr;
2397  return false;
2398 }
2399 
2400 // This version of setValue takes a source location and resets the
2401 // location in the RecordVal.
2402 bool RecordVal::setValue(Init *V, SMLoc NewLoc) {
2403  Loc = NewLoc;
2404  if (V) {
2405  Value = V->getCastTo(getType());
2406  if (Value) {
2407  assert(!isa<TypedInit>(Value) ||
2408  cast<TypedInit>(Value)->getType()->typeIsA(getType()));
2409  if (BitsRecTy *BTy = dyn_cast<BitsRecTy>(getType())) {
2410  if (!isa<BitsInit>(Value)) {
2412  Bits.reserve(BTy->getNumBits());
2413  for (unsigned I = 0, E = BTy->getNumBits(); I < E; ++I)
2414  Bits.push_back(Value->getBit(I));
2416  }
2417  }
2418  }
2419  return Value == nullptr;
2420  }
2421  Value = nullptr;
2422  return false;
2423 }
2424 
2425 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2426 #include "llvm/TableGen/Record.h"
2427 LLVM_DUMP_METHOD void RecordVal::dump() const { errs() << *this; }
2428 #endif
2429 
2430 void RecordVal::print(raw_ostream &OS, bool PrintSem) const {
2431  if (isNonconcreteOK()) OS << "field ";
2432  OS << getPrintType() << " " << getNameInitAsString();
2433 
2434  if (getValue())
2435  OS << " = " << *getValue();
2436 
2437  if (PrintSem) OS << ";\n";
2438 }
2439 
2441  assert(Locs.size() == 1);
2442  ForwardDeclarationLocs.push_back(Locs.front());
2443 
2444  Locs.clear();
2445  Locs.push_back(Loc);
2446 }
2447 
2448 void Record::checkName() {
2449  // Ensure the record name has string type.
2450  const TypedInit *TypedName = cast<const TypedInit>(Name);
2451  if (!isa<StringRecTy>(TypedName->getType()))
2452  PrintFatalError(getLoc(), Twine("Record name '") + Name->getAsString() +
2453  "' is not a string!");
2454 }
2455 
2457  SmallVector<Record *, 4> DirectSCs;
2458  getDirectSuperClasses(DirectSCs);
2459  return RecordRecTy::get(TrackedRecords, DirectSCs);
2460 }
2461 
2463  if (!CorrespondingDefInit) {
2464  CorrespondingDefInit =
2465  new (TrackedRecords.getImpl().Allocator) DefInit(this);
2466  }
2467  return CorrespondingDefInit;
2468 }
2469 
2471  return RK.getImpl().LastRecordID++;
2472 }
2473 
2474 void Record::setName(Init *NewName) {
2475  Name = NewName;
2476  checkName();
2477  // DO NOT resolve record values to the name at this point because
2478  // there might be default values for arguments of this def. Those
2479  // arguments might not have been resolved yet so we don't want to
2480  // prematurely assume values for those arguments were not passed to
2481  // this def.
2482  //
2483  // Nonetheless, it may be that some of this Record's values
2484  // reference the record name. Indeed, the reason for having the
2485  // record name be an Init is to provide this flexibility. The extra
2486  // resolve steps after completely instantiating defs takes care of
2487  // this. See TGParser::ParseDef and TGParser::ParseDefm.
2488 }
2489 
2490 // NOTE for the next two functions:
2491 // Superclasses are in post-order, so the final one is a direct
2492 // superclass. All of its transitive superclases immediately precede it,
2493 // so we can step through the direct superclasses in reverse order.
2494 
2495 bool Record::hasDirectSuperClass(const Record *Superclass) const {
2497 
2498  for (int I = SCs.size() - 1; I >= 0; --I) {
2499  const Record *SC = SCs[I].first;
2500  if (SC == Superclass)
2501  return true;
2502  I -= SC->getSuperClasses().size();
2503  }
2504 
2505  return false;
2506 }
2507 
2510 
2511  while (!SCs.empty()) {
2512  Record *SC = SCs.back().first;
2513  SCs = SCs.drop_back(1 + SC->getSuperClasses().size());
2514  Classes.push_back(SC);
2515  }
2516 }
2517 
2519  Init *OldName = getNameInit();
2520  Init *NewName = Name->resolveReferences(R);
2521  if (NewName != OldName) {
2522  // Re-register with RecordKeeper.
2523  setName(NewName);
2524  }
2525 
2526  // Resolve the field values.
2527  for (RecordVal &Value : Values) {
2528  if (SkipVal == &Value) // Skip resolve the same field as the given one
2529  continue;
2530  if (Init *V = Value.getValue()) {
2531  Init *VR = V->resolveReferences(R);
2532  if (Value.setValue(VR)) {
2533  std::string Type;
2534  if (TypedInit *VRT = dyn_cast<TypedInit>(VR))
2535  Type =
2536  (Twine("of type '") + VRT->getType()->getAsString() + "' ").str();
2538  getLoc(),
2539  Twine("Invalid value ") + Type + "found when setting field '" +
2540  Value.getNameInitAsString() + "' of type '" +
2541  Value.getType()->getAsString() +
2542  "' after resolving references: " + VR->getAsUnquotedString() +
2543  "\n");
2544  }
2545  }
2546  }
2547 
2548  // Resolve the assertion expressions.
2549  for (auto &Assertion : Assertions) {
2550  Init *Value = Assertion.Condition->resolveReferences(R);
2551  Assertion.Condition = Value;
2552  Value = Assertion.Message->resolveReferences(R);
2553  Assertion.Message = Value;
2554  }
2555 }
2556 
2558  RecordResolver R(*this);
2559  R.setName(NewName);
2560  R.setFinal(true);
2561  resolveReferences(R);
2562 }
2563 
2564 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2565 LLVM_DUMP_METHOD void Record::dump() const { errs() << *this; }
2566 #endif
2567 
2569  OS << R.getNameInitAsString();
2570 
2571  ArrayRef<Init *> TArgs = R.getTemplateArgs();
2572  if (!TArgs.empty()) {
2573  OS << "<";
2574  bool NeedComma = false;
2575  for (const Init *TA : TArgs) {
2576  if (NeedComma) OS << ", ";
2577  NeedComma = true;
2578  const RecordVal *RV = R.getValue(TA);
2579  assert(RV && "Template argument record not found??");
2580  RV->print(OS, false);
2581  }
2582  OS << ">";
2583  }
2584 
2585  OS << " {";
2586  ArrayRef<std::pair<Record *, SMRange>> SC = R.getSuperClasses();
2587  if (!SC.empty()) {
2588  OS << "\t//";
2589  for (const auto &SuperPair : SC)
2590  OS << " " << SuperPair.first->getNameInitAsString();
2591  }
2592  OS << "\n";
2593 
2594  for (const RecordVal &Val : R.getValues())
2595  if (Val.isNonconcreteOK() && !R.isTemplateArg(Val.getNameInit()))
2596  OS << Val;
2597  for (const RecordVal &Val : R.getValues())
2598  if (!Val.isNonconcreteOK() && !R.isTemplateArg(Val.getNameInit()))
2599  OS << Val;
2600 
2601  return OS << "}\n";
2602 }
2603 
2605  const RecordVal *R = getValue(FieldName);
2606  if (!R)
2607  PrintFatalError(getLoc(), "Record `" + getName() +
2608  "' does not have a field named `" + FieldName + "'!\n");
2609  return R->getLoc();
2610 }
2611 
2613  const RecordVal *R = getValue(FieldName);
2614  if (!R || !R->getValue())
2615  PrintFatalError(getLoc(), "Record `" + getName() +
2616  "' does not have a field named `" + FieldName + "'!\n");
2617  return R->getValue();
2618 }
2619 
2622  if (!S)
2623  PrintFatalError(getLoc(), "Record `" + getName() +
2624  "' does not have a field named `" + FieldName + "'!\n");
2625  return S.value();
2626 }
2627 
2630  const RecordVal *R = getValue(FieldName);
2631  if (!R || !R->getValue())
2632  return llvm::Optional<StringRef>();
2633  if (isa<UnsetInit>(R->getValue()))
2634  return llvm::Optional<StringRef>();
2635 
2636  if (StringInit *SI = dyn_cast<StringInit>(R->getValue()))
2637  return SI->getValue();
2638 
2640  "Record `" + getName() + "', ` field `" + FieldName +
2641  "' exists but does not have a string initializer!");
2642 }
2643 
2645  const RecordVal *R = getValue(FieldName);
2646  if (!R || !R->getValue())
2647  PrintFatalError(getLoc(), "Record `" + getName() +
2648  "' does not have a field named `" + FieldName + "'!\n");
2649 
2650  if (BitsInit *BI = dyn_cast<BitsInit>(R->getValue()))
2651  return BI;
2652  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" + FieldName +
2653  "' exists but does not have a bits value");
2654 }
2655 
2657  const RecordVal *R = getValue(FieldName);
2658  if (!R || !R->getValue())
2659  PrintFatalError(getLoc(), "Record `" + getName() +
2660  "' does not have a field named `" + FieldName + "'!\n");
2661 
2662  if (ListInit *LI = dyn_cast<ListInit>(R->getValue()))
2663  return LI;
2664  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" + FieldName +
2665  "' exists but does not have a list value");
2666 }
2667 
2668 std::vector<Record*>
2670  ListInit *List = getValueAsListInit(FieldName);
2671  std::vector<Record*> Defs;
2672  for (Init *I : List->getValues()) {
2673  if (DefInit *DI = dyn_cast<DefInit>(I))
2674  Defs.push_back(DI->getDef());
2675  else
2676  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
2677  FieldName + "' list is not entirely DefInit!");
2678  }
2679  return Defs;
2680 }
2681 
2682 int64_t Record::getValueAsInt(StringRef FieldName) const {
2683  const RecordVal *R = getValue(FieldName);
2684  if (!R || !R->getValue())
2685  PrintFatalError(getLoc(), "Record `" + getName() +
2686  "' does not have a field named `" + FieldName + "'!\n");
2687 
2688  if (IntInit *II = dyn_cast<IntInit>(R->getValue()))
2689  return II->getValue();
2690  PrintFatalError(getLoc(), Twine("Record `") + getName() + "', field `" +
2691  FieldName +
2692  "' exists but does not have an int value: " +
2693  R->getValue()->getAsString());
2694 }
2695 
2696 std::vector<int64_t>
2698  ListInit *List = getValueAsListInit(FieldName);
2699  std::vector<int64_t> Ints;
2700  for (Init *I : List->getValues()) {
2701  if (IntInit *II = dyn_cast<IntInit>(I))
2702  Ints.push_back(II->getValue());
2703  else
2705  Twine("Record `") + getName() + "', field `" + FieldName +
2706  "' exists but does not have a list of ints value: " +
2707  I->getAsString());
2708  }
2709  return Ints;
2710 }
2711 
2712 std::vector<StringRef>
2714  ListInit *List = getValueAsListInit(FieldName);
2715  std::vector<StringRef> Strings;
2716  for (Init *I : List->getValues()) {
2717  if (StringInit *SI = dyn_cast<StringInit>(I))
2718  Strings.push_back(SI->getValue());
2719  else
2721  Twine("Record `") + getName() + "', field `" + FieldName +
2722  "' exists but does not have a list of strings value: " +
2723  I->getAsString());
2724  }
2725  return Strings;
2726 }
2727 
2729  const RecordVal *R = getValue(FieldName);
2730  if (!R || !R->getValue())
2731  PrintFatalError(getLoc(), "Record `" + getName() +
2732  "' does not have a field named `" + FieldName + "'!\n");
2733 
2734  if (DefInit *DI = dyn_cast<DefInit>(R->getValue()))
2735  return DI->getDef();
2736  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
2737  FieldName + "' does not have a def initializer!");
2738 }
2739 
2741  const RecordVal *R = getValue(FieldName);
2742  if (!R || !R->getValue())
2743  PrintFatalError(getLoc(), "Record `" + getName() +
2744  "' does not have a field named `" + FieldName + "'!\n");
2745 
2746  if (DefInit *DI = dyn_cast<DefInit>(R->getValue()))
2747  return DI->getDef();
2748  if (isa<UnsetInit>(R->getValue()))
2749  return nullptr;
2750  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
2751  FieldName + "' does not have either a def initializer or '?'!");
2752 }
2753 
2754 
2755 bool Record::getValueAsBit(StringRef FieldName) const {
2756  const RecordVal *R = getValue(FieldName);
2757  if (!R || !R->getValue())
2758  PrintFatalError(getLoc(), "Record `" + getName() +
2759  "' does not have a field named `" + FieldName + "'!\n");
2760 
2761  if (BitInit *BI = dyn_cast<BitInit>(R->getValue()))
2762  return BI->getValue();
2763  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
2764  FieldName + "' does not have a bit initializer!");
2765 }
2766 
2767 bool Record::getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const {
2768  const RecordVal *R = getValue(FieldName);
2769  if (!R || !R->getValue())
2770  PrintFatalError(getLoc(), "Record `" + getName() +
2771  "' does not have a field named `" + FieldName.str() + "'!\n");
2772 
2773  if (isa<UnsetInit>(R->getValue())) {
2774  Unset = true;
2775  return false;
2776  }
2777  Unset = false;
2778  if (BitInit *BI = dyn_cast<BitInit>(R->getValue()))
2779  return BI->getValue();
2780  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
2781  FieldName + "' does not have a bit initializer!");
2782 }
2783 
2785  const RecordVal *R = getValue(FieldName);
2786  if (!R || !R->getValue())
2787  PrintFatalError(getLoc(), "Record `" + getName() +
2788  "' does not have a field named `" + FieldName + "'!\n");
2789 
2790  if (DagInit *DI = dyn_cast<DagInit>(R->getValue()))
2791  return DI;
2792  PrintFatalError(getLoc(), "Record `" + getName() + "', field `" +
2793  FieldName + "' does not have a dag initializer!");
2794 }
2795 
2796 // Check all record assertions: For each one, resolve the condition
2797 // and message, then call CheckAssert().
2798 // Note: The condition and message are probably already resolved,
2799 // but resolving again allows calls before records are resolved.
2801  RecordResolver R(*this);
2802  R.setFinal(true);
2803 
2804  for (const auto &Assertion : getAssertions()) {
2805  Init *Condition = Assertion.Condition->resolveReferences(R);
2806  Init *Message = Assertion.Message->resolveReferences(R);
2807  CheckAssert(Assertion.Loc, Condition, Message);
2808  }
2809 }
2810 
2811 // Report a warning if the record has unused template arguments.
2813  for (const Init *TA : getTemplateArgs()) {
2814  const RecordVal *Arg = getValue(TA);
2815  if (!Arg->isUsed())
2816  PrintWarning(Arg->getLoc(),
2817  "unused template argument: " + Twine(Arg->getName()));
2818  }
2819 }
2820 
2822  : Impl(std::make_unique<detail::RecordKeeperImpl>(*this)) {}
2823 RecordKeeper::~RecordKeeper() = default;
2824 
2825 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2826 LLVM_DUMP_METHOD void RecordKeeper::dump() const { errs() << *this; }
2827 #endif
2828 
2830  OS << "------------- Classes -----------------\n";
2831  for (const auto &C : RK.getClasses())
2832  OS << "class " << *C.second;
2833 
2834  OS << "------------- Defs -----------------\n";
2835  for (const auto &D : RK.getDefs())
2836  OS << "def " << *D.second;
2837  return OS;
2838 }
2839 
2840 /// GetNewAnonymousName - Generate a unique anonymous name that can be used as
2841 /// an identifier.
2843  return AnonymousNameInit::get(*this, getImpl().AnonCounter++);
2844 }
2845 
2846 // These functions implement the phase timing facility. Starting a timer
2847 // when one is already running stops the running one.
2848 
2850  if (TimingGroup) {
2851  if (LastTimer && LastTimer->isRunning()) {
2852  LastTimer->stopTimer();
2853  if (BackendTimer) {
2854  LastTimer->clear();
2855  BackendTimer = false;
2856  }
2857  }
2858 
2859  LastTimer = new Timer("", Name, *TimingGroup);
2860  LastTimer->startTimer();
2861  }
2862 }
2863 
2865  if (TimingGroup) {
2866  assert(LastTimer && "No phase timer was started");
2867  LastTimer->stopTimer();
2868  }
2869 }
2870 
2872  if (TimingGroup) {
2873  startTimer(Name);
2874  BackendTimer = true;
2875  }
2876 }
2877 
2879  if (TimingGroup) {
2880  if (BackendTimer) {
2881  stopTimer();
2882  BackendTimer = false;
2883  }
2884  }
2885 }
2886 
2887 std::vector<Record *>
2889  // We cache the record vectors for single classes. Many backends request
2890  // the same vectors multiple times.
2891  auto Pair = ClassRecordsMap.try_emplace(ClassName);
2892  if (Pair.second)
2893  Pair.first->second = getAllDerivedDefinitions(makeArrayRef(ClassName));
2894 
2895  return Pair.first->second;
2896 }
2897 
2899  ArrayRef<StringRef> ClassNames) const {
2900  SmallVector<Record *, 2> ClassRecs;
2901  std::vector<Record *> Defs;
2902 
2903  assert(ClassNames.size() > 0 && "At least one class must be passed.");
2904  for (const auto &ClassName : ClassNames) {
2905  Record *Class = getClass(ClassName);
2906  if (!Class)
2907  PrintFatalError("The class '" + ClassName + "' is not defined\n");
2908  ClassRecs.push_back(Class);
2909  }
2910 
2911  for (const auto &OneDef : getDefs()) {
2912  if (all_of(ClassRecs, [&OneDef](const Record *Class) {
2913  return OneDef.second->isSubClassOf(Class);
2914  }))
2915  Defs.push_back(OneDef.second.get());
2916  }
2917 
2918  return Defs;
2919 }
2920 
2921 std::vector<Record *>
2923  return getClass(ClassName) ? getAllDerivedDefinitions(ClassName)
2924  : std::vector<Record *>();
2925 }
2926 
2928  auto It = Map.find(VarName);
2929  if (It == Map.end())
2930  return nullptr;
2931 
2932  Init *I = It->second.V;
2933 
2934  if (!It->second.Resolved && Map.size() > 1) {
2935  // Resolve mutual references among the mapped variables, but prevent
2936  // infinite recursion.
2937  Map.erase(It);
2938  I = I->resolveReferences(*this);
2939  Map[VarName] = {I, true};
2940  }
2941 
2942  return I;
2943 }
2944 
2946  Init *Val = Cache.lookup(VarName);
2947  if (Val)
2948  return Val;
2949 
2950  if (llvm::is_contained(Stack, VarName))
2951  return nullptr; // prevent infinite recursion
2952 
2953  if (RecordVal *RV = getCurrentRecord()->getValue(VarName)) {
2954  if (!isa<UnsetInit>(RV->getValue())) {
2955  Val = RV->getValue();
2956  Stack.push_back(VarName);
2957  Val = Val->resolveReferences(*this);
2958  Stack.pop_back();
2959  }
2960  } else if (Name && VarName == getCurrentRecord()->getNameInit()) {
2961  Stack.push_back(VarName);
2962  Val = Name->resolveReferences(*this);
2963  Stack.pop_back();
2964  }
2965 
2966  Cache[VarName] = Val;
2967  return Val;
2968 }
2969 
2971  Init *I = nullptr;
2972 
2973  if (R) {
2974  I = R->resolve(VarName);
2975  if (I && !FoundUnresolved) {
2976  // Do not recurse into the resolved initializer, as that would change
2977  // the behavior of the resolver we're delegating, but do check to see
2978  // if there are unresolved variables remaining.
2980  I->resolveReferences(Sub);
2981  FoundUnresolved |= Sub.FoundUnresolved;
2982  }
2983  }
2984 
2985  if (!I)
2986  FoundUnresolved = true;
2987  return I;
2988 }
2989 
2991 {
2992  if (VarName == VarNameToTrack)
2993  Found = true;
2994  return nullptr;
2995 }
llvm::Init::isComplete
virtual bool isComplete() const
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.h:350
llvm::CondOpInit::getConds
ArrayRef< Init * > getConds() const
Definition: Record.h:1016
llvm::FieldInit::Fold
Init * Fold(Record *CurRec) const
Definition: Record.cpp:2080
i
i
Definition: README.txt:29
llvm::TernOpInit::IF
@ IF
Definition: Record.h:914
llvm::Record::isSubClassOf
bool isSubClassOf(const Record *R) const
Definition: Record.h:1754
llvm::ListInit::isComplete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.cpp:719
llvm::DefInit::getFieldType
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
Definition: Record.cpp:1918
llvm::BinOpInit::XOR
@ XOR
Definition: Record.h:843
llvm::TernOpInit::getOpcode
TernaryOp getOpcode() const
Definition: Record.h:955
llvm::ListInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:735
llvm::ListInit::convertInitListSlice
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This function is used to implement the list slice selection operator.
Definition: Record.cpp:678
llvm::ArrayRef::drop_back
ArrayRef< T > drop_back(size_t N=1) const
Drop the last N elements of the array.
Definition: ArrayRef.h:209
llvm::RecordVal::getPrintType
std::string getPrintType() const
Get the type of the field for printing purposes.
Definition: Record.cpp:2363
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:492
llvm::Timer::clear
void clear()
Clear the timer state.
Definition: Timer.cpp:205
llvm::IsAOpInit::Fold
Init * Fold() const
Definition: Record.cpp:1639
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::tgtok::Def
@ Def
Definition: TGLexer.h:50
llvm::StringRecTy
'string' - Represent an string value
Definition: Record.h:167
llvm::IntInit::convertInitializerTo
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Definition: Record.cpp:533
llvm::VarDefInit::args
ArrayRef< Init * > args() const
Definition: Record.h:1339
llvm::RecordKeeper
Definition: Record.h:1888
llvm::ExistsOpInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1745
llvm::Init::convertInitializerTo
virtual Init * convertInitializerTo(RecTy *Ty) const =0
Convert to a value whose type is Ty, or return null if this is not possible.
llvm::CondOpInit::getCond
Init * getCond(unsigned Num) const
Definition: Record.h:1006
llvm::Init::Opc
uint8_t Opc
Definition: Record.h:329
llvm::TypedInit::getCastTo
Init * getCastTo(RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
Definition: Record.cpp:1789
llvm::AnonymousNameInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:582
llvm::Init::getCastTo
virtual Init * getCastTo(RecTy *Ty) const =0
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
llvm::Record::getDirectSuperClasses
void getDirectSuperClasses(SmallVectorImpl< Record * > &Classes) const
Append the direct superclasses of this record to Classes.
Definition: Record.cpp:2508
llvm::BitsInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:481
llvm::VarListElementInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1898
llvm::UnOpInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:901
llvm::OpInit
Base class for operators.
Definition: Record.h:760
llvm::TernOpInit::FOREACH
@ FOREACH
Definition: Record.h:914
llvm::ListInit::convertInitializerTo
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Definition: Record.cpp:650
llvm::BinOpInit::get
static BinOpInit * get(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type)
Definition: Record.cpp:924
llvm::X86II::TA
@ TA
Definition: X86BaseInfo.h:808
llvm::IntInit::convertInitializerBitRange
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
Definition: Record.cpp:561
T
llvm::Record::getValueAsListOfDefs
std::vector< Record * > getValueAsListOfDefs(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of records,...
Definition: Record.cpp:2669
StringRef.h
llvm::BinOpInit::AND
@ AND
Definition: Record.h:841
llvm::TernOpInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1528
llvm::TypedInit::getFieldType
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
Definition: Record.cpp:1751
llvm::ArrayRef::iterator
const_pointer iterator
Definition: ArrayRef.h:49
llvm::FoldingSetImpl< FoldingSet< T >, T >::InsertNode
void InsertNode(T *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
Definition: FoldingSet.h:497
llvm::RecordKeeper::getImpl
detail::RecordKeeperImpl & getImpl()
Return the internal implementation of the RecordKeeper.
Definition: Record.h:1897
llvm::IsAOpInit
!isa<type>(expr) - Dynamically determine the type of an expression.
Definition: Record.h:1088
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1181
llvm::BitsRecTy::typeIsConvertibleTo
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Definition: Record.cpp:146
llvm::FunctionLoweringInfo::StatepointRelocationRecord
Helper object to track which of three possible relocation mechanisms are used for a particular value ...
Definition: FunctionLoweringInfo.h:95
CheckType
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckType(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const TargetLowering *TLI, const DataLayout &DL)
Definition: SelectionDAGISel.cpp:2549
llvm::OpInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:746
llvm::DagRecTy::get
static DagRecTy * get(RecordKeeper &RK)
Definition: Record.cpp:197
ErrorHandling.h
llvm::FieldInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:2073
llvm::Record::getSuperClasses
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const
Definition: Record.h:1688
ProfileCondOpInit
static void ProfileCondOpInit(FoldingSetNodeID &ID, ArrayRef< Init * > CondRange, ArrayRef< Init * > ValRange, const RecTy *ValType)
Definition: Record.cpp:2103
Allocator.h
llvm::DagInit
(v a, b) - Represent a DAG tree value.
Definition: Record.h:1390
llvm::FieldInit::get
static FieldInit * get(Init *R, StringInit *FN)
Definition: Record.cpp:2059
llvm::tgtok::VarName
@ VarName
Definition: TGLexer.h:72
llvm::detail::RecordKeeperImpl::TheBinOpInitPool
FoldingSet< BinOpInit > TheBinOpInitPool
Definition: Record.cpp:78
llvm::detail::RecordKeeperImpl::LastRecordID
unsigned LastRecordID
Definition: Record.cpp:94
NewExpr
Definition: ItaniumDemangle.h:1934
llvm::detail::RecordKeeperImpl::FalseBitInit
BitInit FalseBitInit
Definition: Record.cpp:70
llvm::detail::RecordKeeperImpl::TheUnsetInit
UnsetInit TheUnsetInit
Definition: Record.cpp:68
llvm::FoldingSetImpl< FoldingSet< T >, T >::FindNodeOrInsertPos
T * FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos)
FindNodeOrInsertPos - Look up the node specified by ID.
Definition: FoldingSet.h:489
llvm::RecordVal::getRecordKeeper
RecordKeeper & getRecordKeeper() const
Get the record keeper used to unique this value.
Definition: Record.h:1510
llvm::RecordKeeper::~RecordKeeper
~RecordKeeper()
llvm::TrackUnresolvedResolver
(Optionally) delegate resolving to a sub-resolver, and keep track whether there were unresolved refer...
Definition: Record.h:2224
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1835
llvm::DagInit::arg_size
size_t arg_size() const
Definition: Record.h:1465
llvm::detail::RecordKeeperImpl::SharedIntRecTy
IntRecTy SharedIntRecTy
Definition: Record.cpp:63
llvm::detail::RecordKeeperImpl::TrueBitInit
BitInit TrueBitInit
Definition: Record.cpp:69
llvm::RecordVal::getNameInitAsString
std::string getNameInitAsString() const
Get the name of the field as a std::string.
Definition: Record.h:1519
llvm::BinOpInit::DIV
@ DIV
Definition: Record.h:840
llvm::RecTy::print
void print(raw_ostream &OS) const
Definition: Record.h:87
llvm::BinOpInit::OR
@ OR
Definition: Record.h:842
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Record::getNewUID
static unsigned getNewUID(RecordKeeper &RK)
Definition: Record.cpp:2470
DenseMap.h
llvm::Timer
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
Definition: Timer.h:81
llvm::IntRecTy
'int' - Represent an integer value of no particular size
Definition: Record.h:149
llvm::BinOpInit
!op (X, Y) - Combine two inits.
Definition: Record.h:834
llvm::tgtok::Bits
@ Bits
Definition: TGLexer.h:50
llvm::BinOpInit::SRA
@ SRA
Definition: Record.h:845
llvm::AnonymousNameInit::getNameInit
StringInit * getNameInit() const
Definition: Record.cpp:578
T1
#define T1
Definition: Mips16ISelLowering.cpp:340
llvm::TernOpInit
!op (X, Y, Z) - Combine two inits.
Definition: Record.h:912
llvm::RecTy::dump
void dump() const
Definition: Record.cpp:104
llvm::DagRecTy
'dag' - Represent a dag fragment
Definition: Record.h:210
llvm::RecTy::BitsRecTyKind
@ BitsRecTyKind
Definition: Record.h:62
llvm::FoldOpInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1607
llvm::Optional
Definition: APInt.h:33
llvm::StringRef::substr
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Definition: StringRef.h:561
llvm::DagInit::getOperatorAsDef
Record * getOperatorAsDef(ArrayRef< SMLoc > Loc) const
Definition: Record.cpp:2292
llvm::BitRecTy::typeIsConvertibleTo
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Definition: Record.cpp:124
llvm::DagInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:2326
llvm::Record::getLoc
ArrayRef< SMLoc > getLoc() const
Definition: Record.h:1656
llvm::BinOpInit::GT
@ GT
Definition: Record.h:857
llvm::TernOpInit::SUBST
@ SUBST
Definition: Record.h:914
llvm::VarBitInit::get
static VarBitInit * get(TypedInit *T, unsigned B)
Definition: Record.cpp:1853
llvm::ListInit::get
static ListInit * get(ArrayRef< Init * > Range, RecTy *EltTy)
Definition: Record.cpp:623
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:891
llvm::Record::checkUnusedTemplateArgs
void checkUnusedTemplateArgs()
Definition: Record.cpp:2812
llvm::FoldOpInit::get
static FoldOpInit * get(Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
Definition: Record.cpp:1555
llvm::detail::RecordKeeperImpl::TheIsAOpInitPool
FoldingSet< IsAOpInit > TheIsAOpInitPool
Definition: Record.cpp:81
ItemApply
static Init * ItemApply(Init *LHS, Init *MHSe, Init *RHS, Record *CurRec)
Definition: Record.cpp:1280
interleaveStringList
static StringInit * interleaveStringList(const ListInit *List, const StringInit *Delim)
Definition: Record.cpp:951
ProfileDagInit
static void ProfileDagInit(FoldingSetNodeID &ID, Init *V, StringInit *VN, ArrayRef< Init * > ArgRange, ArrayRef< StringInit * > NameRange)
Definition: Record.cpp:2235
llvm::Init::getBit
virtual Init * getBit(unsigned Bit) const =0
Get the Init value of the specified bit.
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
llvm::BinOpInit::getStrConcat
static Init * getStrConcat(Init *lhs, Init *rhs)
Definition: Record.cpp:994
resolveRecordTypes
static RecordRecTy * resolveRecordTypes(RecordRecTy *T1, RecordRecTy *T2)
Definition: Record.cpp:300
llvm::TernOpInit::SUBSTR
@ SUBSTR
Definition: Record.h:914
llvm::Record::getValueAsOptionalDef
Record * getValueAsOptionalDef(StringRef FieldName) const
This method looks up the specified field and returns its value as a Record, returning null if the fie...
Definition: Record.cpp:2740
llvm::RecordVal::FieldKind
FieldKind
Definition: Record.h:1489
llvm::Timer::startTimer
void startTimer()
Start the timer running.
Definition: Timer.cpp:190
llvm::DagInit::getArg
Init * getArg(unsigned Num) const
Definition: Record.h:1431
llvm::VarInit
'Opcode' - Represent a reference to an entire variable object.
Definition: Record.h:1155
llvm::Record::getFieldLoc
SMLoc getFieldLoc(StringRef FieldName) const
Return the source location for the named field.
Definition: Record.cpp:2604
llvm::AnonymousNameInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:586
llvm::DagInit::getOperator
Init * getOperator() const
Definition: Record.h:1420
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:159
llvm::RecTy
Definition: Record.h:57
llvm::detail::RecordKeeperImpl::TheExistsOpInitPool
FoldingSet< ExistsOpInit > TheExistsOpInitPool
Definition: Record.cpp:82
llvm::ListRecTy::typeIsA
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
Definition: Record.cpp:191
llvm::TernOpInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:1276
llvm::BitRecTy
'bit' - Represent a single bit
Definition: Record.h:108
llvm::TernOpInit::Fold
Init * Fold(Record *CurRec) const
Definition: Record.cpp:1360
llvm::Record::getValueAsListInit
ListInit * getValueAsListInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a ListInit, throwing an exception i...
Definition: Record.cpp:2656
llvm::detail::RecordKeeperImpl::TheVarListElementInitPool
DenseMap< std::pair< TypedInit *, unsigned >, VarListElementInit * > TheVarListElementInitPool
Definition: Record.cpp:86
llvm::CondOpInit::Fold
Init * Fold(Record *CurRec) const
Definition: Record.cpp:2174
llvm::ListInit::getElementType
RecTy * getElementType() const
Definition: Record.h:722
llvm::BinOpInit::getLHS
Init * getLHS() const
Definition: Record.h:899
llvm::BitsRecTy
'bits<n>' - Represent a fixed number of bits
Definition: Record.h:126
llvm::RecordKeeper::startBackendTimer
void startBackendTimer(StringRef Name)
Start timing the overall backend.
Definition: Record.cpp:2871
llvm::Timer::isRunning
bool isRunning() const
Check if the timer is currently running.
Definition: Timer.h:118
llvm::detail::RecordKeeperImpl::AnonCounter
unsigned AnonCounter
Definition: Record.cpp:93
llvm::Resolver
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2133
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:187
llvm::Record::getTemplateArgs
ArrayRef< Init * > getTemplateArgs() const
Definition: Record.h:1680
llvm::tgtok::Dag
@ Dag
Definition: TGLexer.h:50
llvm::detail::RecordKeeperImpl::RecordTypePool
FoldingSet< RecordRecTy > RecordTypePool
Definition: Record.cpp:91
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::detail::RecordKeeperImpl::SharedStringRecTy
StringRecTy SharedStringRecTy
Definition: Record.cpp:64
llvm::StringInit::SF_String
@ SF_String
Definition: Record.h:641
llvm::BinOpInit::getRHS
Init * getRHS() const
Definition: Record.h:900
llvm::all_of
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1590
llvm::Record::resolveReferences
void resolveReferences(Init *NewName=nullptr)
If there are any field references that refer to fields that have been filled in, we can propagate the...
Definition: Record.cpp:2557
llvm::RecTy::getRecordKeeper
RecordKeeper & getRecordKeeper() const
Return the RecordKeeper that uniqued this Type.
Definition: Record.h:84
llvm::RecordKeeper::startTimer
void startTimer(StringRef Name)
Start timing a phase. Automatically stops any previous phase timer.
Definition: Record.cpp:2849
llvm::ArrayRef::back
const T & back() const
back - Get the last element.
Definition: ArrayRef.h:173
llvm::BitsInit::isConcrete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:459
llvm::detail::RecordKeeperImpl::RecordKeeperImpl
RecordKeeperImpl(RecordKeeper &RK)
Definition: Record.cpp:53
llvm::CondOpInit::getVals
ArrayRef< Init * > getVals() const
Definition: Record.h:1020
llvm::UnOpInit::GETDAGOP
@ GETDAGOP
Definition: Record.h:787
llvm::PPCISD::SC
@ SC
CHAIN = SC CHAIN, Imm128 - System call.
Definition: PPCISelLowering.h:418
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::BitInit::get
static BitInit * get(RecordKeeper &RK, bool V)
Definition: Record.cpp:371
llvm::VarDefInit::getArg
Init * getArg(unsigned i) const
Definition: Record.h:1326
llvm::VarListElementInit::getElementNum
unsigned getElementNum() const
Definition: Record.h:1253
SmallString.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::StringRecTy::typeIsConvertibleTo
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Definition: Record.cpp:176
llvm::FoldOpInit
!foldl (a, b, expr, start, lst) - Fold over a list.
Definition: Record.h:1051
llvm::BitsInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:467
llvm::CheckAssert
void CheckAssert(SMLoc Loc, Init *Condition, Init *Message)
Definition: Error.cpp:159
llvm::UnOpInit::UnaryOp
UnaryOp
Definition: Record.h:787
llvm::IsAOpInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:1659
llvm::DagInit::arg_empty
bool arg_empty() const
Definition: Record.h:1466
llvm::BinOpInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:1212
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::BinOpInit::BinaryOp
BinaryOp
Definition: Record.h:836
llvm::ListRecTy::getElementType
RecTy * getElementType() const
Definition: Record.h:200
llvm::TrackUnresolvedResolver::resolve
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.cpp:2970
llvm::Init::getRecordKeeper
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
Definition: Record.cpp:353
llvm::RecordKeeper::addDef
void addDef(std::unique_ptr< Record > R)
Definition: Record.h:1942
llvm::CondOpInit
!cond(condition_1: value1, ...
Definition: Record.h:976
llvm::DagInit::isConcrete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:2316
llvm::UnOpInit::CAST
@ CAST
Definition: Record.h:787
llvm::DagRecTy::getAsString
std::string getAsString() const override
Definition: Record.cpp:201
IP
Definition: NVPTXLowerArgs.cpp:168
llvm::Init::dump
void dump() const
Debugging method that may be called through a debugger; just invokes print on stderr.
Definition: Record.cpp:350
false
Definition: StackSlotColoring.cpp:141
llvm::RecordKeeper::stopBackendTimer
void stopBackendTimer()
Stop timing the overall backend.
Definition: Record.cpp:2878
llvm::BinOpInit::ADD
@ ADD
Definition: Record.h:837
llvm::TernOpInit::getRHS
Init * getRHS() const
Definition: Record.h:958
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
First
into llvm powi allowing the code generator to produce balanced multiplication trees First
Definition: README.txt:54
llvm::detail::RecordKeeperImpl::TheListInitPool
FoldingSet< ListInit > TheListInitPool
Definition: Record.cpp:76
llvm::ListInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
Definition: Record.cpp:703
Concat
static constexpr int Concat[]
Definition: X86InterleavedAccess.cpp:239
SMLoc.h
llvm::TypedInit::getType
RecTy * getType() const
Get the type of the Init as a RecTy.
Definition: Record.h:438
llvm::PrintFatalError
void PrintFatalError(const Twine &Msg)
Definition: Error.cpp:125
ProfileListInit
static void ProfileListInit(FoldingSetNodeID &ID, ArrayRef< Init * > Range, RecTy *EltTy)
Definition: Record.cpp:613
llvm::Record::getNameInitAsString
std::string getNameInitAsString() const
Definition: Record.h:1650
llvm::RecordRecTy::getAsString
std::string getAsString() const override
Definition: Record.cpp:260
llvm::ExistsOpInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1741
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::BinOpInit::getListConcat
static Init * getListConcat(TypedInit *lhs, Init *rhs)
Definition: Record.cpp:1011
llvm::DefInit::getDef
Record * getDef() const
Definition: Record.h:1281
llvm::wasm::ValType
ValType
Definition: Wasm.h:424
llvm::detail::RecordKeeperImpl::TheFoldOpInitPool
FoldingSet< FoldOpInit > TheFoldOpInitPool
Definition: Record.cpp:80
llvm::ListInit::isConcrete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:727
llvm::detail::RecordKeeperImpl::Allocator
BumpPtrAllocator Allocator
Definition: Record.cpp:60
llvm::IsAOpInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1666
llvm::VarDefInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:1958
llvm::BitsInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:571
llvm::TernOpInit::get
static TernOpInit * get(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type)
Definition: Record.cpp:1261
llvm::RecordVal::getValue
Init * getValue() const
Get the value of the field as an Init.
Definition: Record.h:1543
llvm::CondOpInit::getNumConds
unsigned getNumConds() const
Definition: Record.h:1004
llvm::IntInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:523
llvm::CondOpInit::get
static CondOpInit * get(ArrayRef< Init * > C, ArrayRef< Init * > V, RecTy *Type)
Definition: Record.cpp:2126
llvm::ShadowResolver::addShadow
void addShadow(Init *Key)
Definition: Record.h:2213
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::AnonymousNameInit
"anonymous_n" - Represent an anonymous record name
Definition: Record.h:608
llvm::FieldInit
X.Y - Represent a reference to a subfield of a variable.
Definition: Record.h:1347
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:110
llvm::SmallString
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
llvm::TernOpInit::DAG
@ DAG
Definition: Record.h:914
llvm::RecordVal::dump
void dump() const
Definition: Record.cpp:2427
llvm::Record::dump
void dump() const
Definition: Record.cpp:2565
llvm::IsAOpInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1670
llvm::BinOpInit::LISTSPLAT
@ LISTSPLAT
Definition: Record.h:848
llvm::BitInit::convertInitializerTo
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Definition: Record.cpp:375
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1538
llvm::TernOpInit::TernaryOp
TernaryOp
Definition: Record.h:914
llvm::RecordRecTy::typeIsA
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
Definition: Record.cpp:296
llvm::Record::getAssertions
ArrayRef< AssertionInfo > getAssertions() const
Definition: Record.h:1686
llvm::BinOpInit::NE
@ NE
Definition: Record.h:853
llvm::VarBitInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1861
llvm::CondOpInit::isConcrete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:2196
llvm::FieldInit::isConcrete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:2095
llvm::detail::RecordKeeperImpl::TheTernOpInitPool
FoldingSet< TernOpInit > TheTernOpInitPool
Definition: Record.cpp:79
ProfileBinOpInit
static void ProfileBinOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *RHS, RecTy *Type)
Definition: Record.cpp:916
llvm::UnOpInit
!op (X) - Transform an init.
Definition: Record.h:785
Error.h
FilterHelper
static Init * FilterHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, Record *CurRec)
Definition: Record.cpp:1336
llvm::RecordVal::setValue
bool setValue(Init *V)
Set the value of the field from an Init.
Definition: Record.cpp:2378
llvm::Resolver::getCurrentRecord
Record * getCurrentRecord() const
Definition: Record.h:2141
llvm::Init::isConcrete
virtual bool isConcrete() const
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.h:354
llvm::UnsetInit::convertInitializerTo
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Definition: Record.cpp:367
llvm::VarListElementInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:1885
llvm::BitInit::getValue
bool getValue() const
Definition: Record.h:512
llvm::IsAOpInit::get
static IsAOpInit * get(RecTy *CheckType, Init *Expr)
Definition: Record.cpp:1620
llvm::IntInit
'7' - Represent an initialization by a literal integer value.
Definition: Record.h:578
llvm::Record::getDefInit
DefInit * getDefInit()
get the corresponding DefInit.
Definition: Record.cpp:2462
llvm::DefInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1924
llvm::DefInit::convertInitializerTo
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Definition: Record.cpp:1911
llvm::ListInit
[AL, AH, CL] - Represent a list of defs
Definition: Record.h:693
uint64_t
llvm::StringInit::convertInitializerTo
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Definition: Record.cpp:606
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::Record::updateClassLoc
void updateClassLoc(SMLoc Loc)
Definition: Record.cpp:2440
llvm::MapResolver
Resolve arbitrary mappings.
Definition: Record.h:2161
llvm::RecordVal::print
void print(raw_ostream &OS, bool PrintSem=true) const
Print the value to an output stream, possibly with a semicolon.
Definition: Record.cpp:2430
llvm::BitsInit::get
static BitsInit * get(RecordKeeper &RK, ArrayRef< Init * > Range)
Definition: Record.cpp:399
llvm::detail::RecordKeeperImpl::TheBitsInitPool
FoldingSet< BitsInit > TheBitsInitPool
Definition: Record.cpp:72
llvm::Record::getValues
ArrayRef< RecordVal > getValues() const
Definition: Record.h:1684
llvm::DefInit
AL - Represent a reference to a 'def' in the description.
Definition: Record.h:1262
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:63
llvm::TernOpInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:1498
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:53
llvm::DenseMap
Definition: DenseMap.h:714
llvm::VarInit::get
static VarInit * get(StringRef VN, RecTy *T)
Definition: Record.cpp:1823
llvm::RecordRecTy
'[classname]' - Type of record values that have zero or more superclasses.
Definition: Record.h:229
llvm::ShadowResolver
Delegate resolving to a sub-resolver, but shadow some variable names.
Definition: Record.h:2203
llvm::detail::RecordKeeperImpl::TheVarInitPool
DenseMap< std::pair< RecTy *, Init * >, VarInit * > TheVarInitPool
Definition: Record.cpp:83
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::Record::addValue
void addValue(const RecordVal &RV)
Definition: Record.h:1725
llvm::ListInit::size
size_t size() const
Definition: Record.h:750
StringExtras.h
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1673
ArrayRef.h
ProfileTernOpInit
static void ProfileTernOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *LHS, Init *MHS, Init *RHS, RecTy *Type)
Definition: Record.cpp:1252
llvm::IntInit::getValue
int64_t getValue() const
Definition: Record.h:594
llvm::Record::checkRecordAssertions
void checkRecordAssertions()
Definition: Record.cpp:2800
llvm::detail::RecordKeeperImpl::TheDagInitPool
FoldingSet< DagInit > TheDagInitPool
Definition: Record.cpp:90
llvm::BitsRecTy::typeIsA
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
Definition: Record.cpp:153
llvm::resolveTypes
RecTy * resolveTypes(RecTy *T1, RecTy *T2)
Find a common type that T1 and T2 convert to.
Definition: Record.cpp:317
llvm::BinOpInit::GE
@ GE
Definition: Record.h:856
llvm::BinOpInit::SHL
@ SHL
Definition: Record.h:844
llvm::ExistsOpInit::get
static ExistsOpInit * get(RecTy *CheckType, Init *Expr)
Definition: Record.cpp:1682
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ListRecTy
'list<Ty>' - Represent a list of element values, all of which must be of the specified type.
Definition: Record.h:186
llvm::Record::getValueAsListOfStrings
std::vector< StringRef > getValueAsListOfStrings(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of strings,...
Definition: Record.cpp:2713
llvm::RecordKeeper::RecordKeeper
RecordKeeper()
Definition: Record.cpp:2821
llvm::FoldOpInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:1588
SI
StandardInstrumentations SI(Debug, VerifyEach)
llvm::TypedInit::convertInitializerBitRange
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
Definition: Record.cpp:1773
llvm::BinOpInit::Fold
Init * Fold(Record *CurRec) const
Definition: Record.cpp:1021
llvm::RecordKeeper::getAllDerivedDefinitionsIfDefined
std::vector< Record * > getAllDerivedDefinitionsIfDefined(StringRef ClassName) const
Get all the concrete records that inherit from specified class, if the class is defined.
Definition: Record.cpp:2922
llvm::Init::resolveReferences
virtual Init * resolveReferences(Resolver &R) const
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.h:407
llvm::BinOpInit::LISTCONCAT
@ LISTCONCAT
Definition: Record.h:847
llvm::Init::getAsUnquotedString
virtual std::string getAsUnquotedString() const
Convert this value to a literal form, without adding quotes around a string.
Definition: Record.h:364
ProfileExistsOpInit
static void ProfileExistsOpInit(FoldingSetNodeID &ID, RecTy *CheckType, Init *Expr)
Definition: Record.cpp:1676
llvm::Record::removeValue
void removeValue(Init *Name)
Definition: Record.h:1730
llvm::Record::getValueAsListOfInts
std::vector< int64_t > getValueAsListOfInts(StringRef FieldName) const
This method looks up the specified field and returns its value as a vector of integers,...
Definition: Record.cpp:2697
llvm::BinOpInit::EQ
@ EQ
Definition: Record.h:852
llvm::Timer::stopTimer
void stopTimer()
Stop the timer.
Definition: Timer.cpp:197
llvm::IntInit::get
static IntInit * get(RecordKeeper &RK, int64_t V)
Definition: Record.cpp:516
llvm::VarBitInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:1865
B
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional ldr LCPI1_0 ldr ldr tst movne lsr ldr LCPI1_1 and r0 bx lr it saves an instruction and a register It might be profitable to cse MOVi16 if there are lots of bit immediates with the same bottom half Robert Muth started working on an alternate jump table implementation that does not put the tables in line in the text This is more like the llvm default jump table implementation This might be useful sometime Several revisions of patches are on the mailing beginning while CMP sets them like a subtract Therefore to be able to use CMN for comparisons other than the Z we ll need additional logic to reverse the conditionals associated with the comparison Perhaps a pseudo instruction for the with a post codegen pass to clean up and handle the condition codes See PR5694 for testcase Given the following on int B
Definition: README.txt:592
ProfileRecordRecTy
static void ProfileRecordRecTy(FoldingSetNodeID &ID, ArrayRef< Record * > Classes)
Definition: Record.cpp:205
llvm::Record::getValueAsDag
DagInit * getValueAsDag(StringRef FieldName) const
This method looks up the specified field and returns its value as an Dag, throwing an exception if th...
Definition: Record.cpp:2784
llvm::RecordKeeper::getDefs
const RecordMap & getDefs() const
Get the map of records (defs).
Definition: Record.h:1906
llvm::Record
Definition: Record.h:1573
ConcatListInits
static ListInit * ConcatListInits(const ListInit *LHS, const ListInit *RHS)
Definition: Record.cpp:1003
llvm::VarInit::getName
StringRef getName() const
Definition: Record.cpp:1836
ProfileIsAOpInit
static void ProfileIsAOpInit(FoldingSetNodeID &ID, RecTy *CheckType, Init *Expr)
Definition: Record.cpp:1614
llvm::MapResolver::resolve
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.cpp:2927
llvm::ExistsOpInit
!exists<type>(expr) - Dynamically determine if a record of type named expr exists.
Definition: Record.h:1122
llvm::RecordKeeper::getClass
Record * getClass(StringRef Name) const
Get the class with the specified name.
Definition: Record.h:1912
llvm::BinOpInit::SUB
@ SUB
Definition: Record.h:838
llvm::Init::getAsString
virtual std::string getAsString() const =0
Convert this value to a literal form.
llvm::StringRecTy::getAsString
std::string getAsString() const override
Definition: Record.cpp:172
llvm::UnOpInit::NOT
@ NOT
Definition: Record.h:787
llvm::Record::getValueAsBitsInit
BitsInit * getValueAsBitsInit(StringRef FieldName) const
This method looks up the specified field and returns its value as a BitsInit, throwing an exception i...
Definition: Record.cpp:2644
llvm::VarInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.h:1188
llvm::Record::getType
RecordRecTy * getType()
Definition: Record.cpp:2456
getType
static M68kRelType getType(unsigned Kind, MCSymbolRefExpr::VariantKind &Modifier, bool &IsPCRel)
Definition: M68kELFObjectWriter.cpp:48
llvm::RecordKeeper::getClasses
const RecordMap & getClasses() const
Get the map of classes.
Definition: Record.h:1903
llvm::TypedInit::convertInitializerTo
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Definition: Record.cpp:1762
llvm::VarInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This method is used by classes that refer to other variables which may not be defined at the time the...
Definition: Record.cpp:1847
llvm::StringInit
"foo" - Represent an initialization by a string value.
Definition: Record.h:638
llvm::BitsInit::convertInitializerTo
Init * convertInitializerTo(RecTy *Ty) const override
Convert to a value whose type is Ty, or return null if this is not possible.
Definition: Record.cpp:421
llvm::BinOpInit::INTERLEAVE
@ INTERLEAVE
Definition: Record.h:850
llvm::FoldingSet
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
Definition: FoldingSet.h:520
llvm::RecordKeeper::getAllDerivedDefinitions
std::vector< Record * > getAllDerivedDefinitions(StringRef ClassName) const
Get all the concrete records that inherit from the one specified class.
Definition: Record.cpp:2888
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::Record::addSuperClass
void addSuperClass(Record *R, SMRange Range)
Definition: Record.h:1773
llvm::CondOpInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:2220
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1597
llvm::UnOpInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:773
Cond
SmallVector< MachineOperand, 4 > Cond
Definition: BasicBlockSections.cpp:137
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm::BitsInit::getNumBits
unsigned getNumBits() const
Definition: Record.h:549
llvm::TernOpInit::getLHS
Init * getLHS() const
Definition: Record.h:956
llvm::BitInit
'true'/'false' - Represent a concrete initializer for a bit.
Definition: Record.h:495
llvm::TrailingObjects::getTrailingObjects
const T * getTrailingObjects() const
Returns a pointer to the trailing object array of the given type (which must be one of those specifie...
Definition: TrailingObjects.h:285
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::CondOpInit::getVal
Init * getVal(unsigned Num) const
Definition: Record.h:1011
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::RecordVal::getNameInit
Init * getNameInit() const
Get the name of the field as an Init.
Definition: Record.h:1516
llvm::RecTy::typeIsA
virtual bool typeIsA(const RecTy *RHS) const
Return true if 'this' type is equal to or a subtype of RHS.
Definition: Record.cpp:118
llvm::Record::getNameInit
Init * getNameInit() const
Definition: Record.h:1646
llvm::RecordRecTy::getClasses
ArrayRef< Record * > getClasses() const
Definition: Record.h:256
Compiler.h
llvm::CondOpInit::isComplete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.cpp:2208
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:1818
llvm::FoldOpInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:1570
llvm::detail::RecordKeeperImpl::SharedBitRecTy
BitRecTy SharedBitRecTy
Definition: Record.cpp:62
llvm::FoldingSetNodeID
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:318
llvm::ListInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:644
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::VarDefInit::args_size
size_t args_size() const
Definition: Record.h:1336
llvm::DagInit::getArgNames
ArrayRef< StringInit * > getArgNames() const
Definition: Record.h:1450
ForeachHelper
static Init * ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, Record *CurRec)
Definition: Record.cpp:1315
llvm::DagInit::getArgs
ArrayRef< Init * > getArgs() const
Definition: Record.h:1446
llvm::Init
Definition: Record.h:281
llvm::Record::getValueAsBitOrUnset
bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const
This method looks up the specified field and returns its value as a bit.
Definition: Record.cpp:2767
llvm::RecTy::getListTy
ListRecTy * getListTy()
Returns the type representing list<thistype>.
Definition: Record.cpp:107
llvm::IsAOpInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:1635
llvm::RecordVal::getName
StringRef getName() const
Get the name of the field as a StringRef.
Definition: Record.cpp:2359
llvm::RecordKeeper::stopTimer
void stopTimer()
Stop timing a phase.
Definition: Record.cpp:2864
FoldingSet.h
llvm::Record::getValueAsInt
int64_t getValueAsInt(StringRef FieldName) const
This method looks up the specified field and returns its value as an int64_t, throwing an exception i...
Definition: Record.cpp:2682
llvm::BitsInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:417
llvm::DagInit::getNumArgs
unsigned getNumArgs() const
Definition: Record.h:1429
llvm::StringRef::size
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
llvm::CondOpInit::getValType
RecTy * getValType() const
Definition: Record.h:1002
j
return j(j<< 16)
llvm::HasReferenceResolver::resolve
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.cpp:2990
llvm::BitsInit::convertInitializerBitRange
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
Definition: Record.cpp:448
llvm::BitsRecTy::get
static BitsRecTy * get(RecordKeeper &RK, unsigned Sz)
Definition: Record.cpp:132
llvm::ListInit::getValues
ArrayRef< Init * > getValues() const
Definition: Record.h:743
llvm::UnsetInit
'?' - Represents an uninitialized value.
Definition: Record.h:456
llvm::DagInit::get
static DagInit * get(Init *V, StringInit *VN, ArrayRef< Init * > ArgRange, ArrayRef< StringInit * > NameRange)
Definition: Record.cpp:2251
llvm::UnOpInit::SIZE
@ SIZE
Definition: Record.h:787
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::BinOpInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1222
ProfileFoldOpInit
static void ProfileFoldOpInit(FoldingSetNodeID &ID, Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
Definition: Record.cpp:1545
llvm::TernOpInit::getMHS
Init * getMHS() const
Definition: Record.h:957
llvm::RecordVal::getType
RecTy * getType() const
Get the type of the field value as a RecTy.
Definition: Record.h:1537
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
llvm::UnOpInit::get
static UnOpInit * get(UnaryOp opc, Init *lhs, RecTy *Type)
Definition: Record.cpp:759
llvm::StringRecTy::get
static StringRecTy * get(RecordKeeper &RK)
Definition: Record.cpp:168
llvm::BinOpInit::SRL
@ SRL
Definition: Record.h:846
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
llvm::TernOpInit::FILTER
@ FILTER
Definition: Record.h:914
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:348
llvm::Resolver::resolve
virtual Init * resolve(Init *VarName)=0
Return the initializer for the given variable name (should normally be a StringInit),...
llvm::ArrayRef::begin
iterator begin() const
Definition: ArrayRef.h:152
llvm::RecordVal::isNonconcreteOK
bool isNonconcreteOK() const
Is this a field where nonconcrete values are okay?
Definition: Record.h:1527
llvm::detail::RecordKeeperImpl::TheUnOpInitPool
FoldingSet< UnOpInit > TheUnOpInitPool
Definition: Record.cpp:77
llvm::VarDefInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:2014
llvm::Record::getRecords
RecordKeeper & getRecords() const
Definition: Record.h:1794
llvm::BinOpInit::getOpcode
BinaryOp getOpcode() const
Definition: Record.h:898
llvm::BumpPtrAllocatorImpl::Allocate
LLVM_ATTRIBUTE_RETURNS_NONNULL void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:148
llvm::Record::getValue
const RecordVal * getValue(const Init *Name) const
Definition: Record.h:1702
llvm::VarInit::getNameInit
Init * getNameInit() const
Definition: Record.h:1173
llvm::StringInit::getValue
StringRef getValue() const
Definition: Record.h:667
llvm::FieldInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:2067
llvm::RecordResolver::resolve
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.cpp:2945
Casting.h
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
interleaveIntList
static StringInit * interleaveIntList(const ListInit *List, const StringInit *Delim)
Definition: Record.cpp:972
llvm::VarBitInit::getBitNum
unsigned getBitNum() const
Definition: Record.h:1217
llvm::TypedInit::getRecordKeeper
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
Definition: Record.h:441
llvm::UnOpInit::TAIL
@ TAIL
Definition: Record.h:787
llvm::detail::RecordKeeperImpl
This class represents the internal implementation of the RecordKeeper.
Definition: Record.cpp:52
llvm::ListRecTy::typeIsConvertibleTo
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Definition: Record.cpp:185
llvm::Record::getValueInit
Init * getValueInit(StringRef FieldName) const
Return the initializer for a value with the specified name, or throw an exception if the field does n...
Definition: Record.cpp:2612
llvm::UnOpInit::HEAD
@ HEAD
Definition: Record.h:787
ProfileVarDefInit
static void ProfileVarDefInit(FoldingSetNodeID &ID, Record *Class, ArrayRef< Init * > Args)
Definition: Record.cpp:1926
llvm::RecTy::StringRecTyKind
@ StringRecTyKind
Definition: Record.h:64
llvm::ListRecTy::getAsString
std::string getAsString() const override
Definition: Record.cpp:181
ProfileBitsInit
static void ProfileBitsInit(FoldingSetNodeID &ID, ArrayRef< Init * > Range)
Definition: Record.cpp:392
llvm::Init::print
void print(raw_ostream &OS) const
Print this value.
Definition: Record.h:357
llvm::ExistsOpInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:1734
llvm::RecordRecTy::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:256
llvm::CondOpInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:2231
llvm::tgtok::Class
@ Class
Definition: TGLexer.h:50
llvm::VarListElementInit::get
static VarListElementInit * get(TypedInit *T, unsigned E)
Definition: Record.cpp:1873
llvm::makeArrayRef
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:475
llvm::UnsetInit::getCastTo
Init * getCastTo(RecTy *Ty) const override
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
Definition: Record.cpp:363
llvm::detail::RecordKeeperImpl::TheVarBitInitPool
DenseMap< std::pair< TypedInit *, unsigned >, VarBitInit * > TheVarBitInitPool
Definition: Record.cpp:84
llvm::RecTy::typeIsConvertibleTo
virtual bool typeIsConvertibleTo(const RecTy *RHS) const
Return true if all values of 'this' type can be converted to the specified type.
Definition: Record.cpp:113
llvm::CondOpInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:2151
llvm::BinOpInit::LT
@ LT
Definition: Record.h:855
llvm::TernOpInit::FIND
@ FIND
Definition: Record.h:914
llvm::RecTy::getAsString
virtual std::string getAsString() const =0
llvm::BinOpInit::SETDAGOP
@ SETDAGOP
Definition: Record.h:858
llvm::RecordVal::RecordVal
RecordVal(Init *N, RecTy *T, FieldKind K)
Definition: Record.cpp:2345
ProfileUnOpInit
static void ProfileUnOpInit(FoldingSetNodeID &ID, unsigned Opcode, Init *Op, RecTy *Type)
Definition: Record.cpp:753
SmallVector.h
llvm::Record::getName
StringRef getName() const
Definition: Record.h:1644
llvm::RecTy::BitRecTyKind
@ BitRecTyKind
Definition: Record.h:61
llvm::detail::RecordKeeperImpl::TheFieldInitPool
DenseMap< std::pair< Init *, StringInit * >, FieldInit * > TheFieldInitPool
Definition: Record.cpp:88
llvm::RecordRecTy::get
static RecordRecTy * get(RecordKeeper &RK, ArrayRef< Record * > Classes)
Get the record type with the given non-redundant list of superclasses.
Definition: Record.cpp:212
llvm::ListInit::getElementAsRecord
Record * getElementAsRecord(unsigned i) const
Definition: Record.cpp:695
llvm::PrintError
void PrintError(const Twine &Msg)
Definition: Error.cpp:101
llvm::FoldOpInit::Fold
Init * Fold(Record *CurRec) const
Definition: Record.cpp:1574
llvm::SMRange
Represents a range in source code.
Definition: SMLoc.h:48
List
const NodeList & List
Definition: RDFGraph.cpp:199
llvm::UnOpInit::Fold
Init * Fold(Record *CurRec, bool IsFinal=false) const
Definition: Record.cpp:777
N
#define N
llvm::StringInit::determineFormat
static StringFormat determineFormat(StringFormat Fmt1, StringFormat Fmt2)
Definition: Record.h:663
llvm::Record::getValueAsBit
bool getValueAsBit(StringRef FieldName) const
This method looks up the specified field and returns its value as a bit, throwing an exception if the...
Definition: Record.cpp:2755
llvm::Record::appendAssertions
void appendAssertions(const Record *Rec)
Definition: Record.h:1747
llvm::detail::RecordKeeperImpl::StringInitStringPool
StringMap< StringInit *, BumpPtrAllocator & > StringInitStringPool
Definition: Record.cpp:74
llvm::RecTy::RecTyKind
RecTyKind
Subclass discriminator (for dyn_cast<> et al.)
Definition: Record.h:60
llvm::VarBitInit
Opcode{0} - Represent access to one bit of a variable or field.
Definition: Record.h:1192
llvm::CondOpInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:2119
llvm::TrackUnresolvedResolver::foundUnresolved
bool foundUnresolved() const
Definition: Record.h:2232
llvm::to_string
std::string to_string(const T &Value)
Definition: ScopedPrinter.h:85
llvm::BinOpInit::STRCONCAT
@ STRCONCAT
Definition: Record.h:849
llvm::PrintWarning
void PrintWarning(const Twine &Msg)
Definition: Error.cpp:89
llvm::ArrayRef::size
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:164
llvm::Record::getValueAsString
StringRef getValueAsString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
Definition: Record.cpp:2620
llvm::RecordKeeper::getNewAnonymousName
Init * getNewAnonymousName()
GetNewAnonymousName - Generate a unique anonymous name that can be used as an identifier.
Definition: Record.cpp:2842
llvm::DagInit::getArgName
StringInit * getArgName(unsigned Num) const
Definition: Record.h:1436
canFitInBitfield
static bool canFitInBitfield(int64_t Value, unsigned NumBits)
Definition: Record.cpp:527
llvm::tgtok::Bit
@ Bit
Definition: TGLexer.h:50
llvm::BitsRecTy::getAsString
std::string getAsString() const override
Definition: Record.cpp:142
llvm::UnOpInit::getOperand
Init * getOperand() const
Definition: Record.h:822
llvm::detail::RecordKeeperImpl::TheVarDefInitPool
FoldingSet< VarDefInit > TheVarDefInitPool
Definition: Record.cpp:87
llvm::UnOpInit::EMPTY
@ EMPTY
Definition: Record.h:787
llvm::detail::RecordKeeperImpl::SharedBitsRecTys
std::vector< BitsRecTy * > SharedBitsRecTys
Definition: Record.cpp:61
llvm::BinOpInit::MUL
@ MUL
Definition: Record.h:839
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::detail::RecordKeeperImpl::TheCondOpInitPool
FoldingSet< CondOpInit > TheCondOpInitPool
Definition: Record.cpp:89
llvm::detail::RecordKeeperImpl::StringInitCodePool
StringMap< StringInit *, BumpPtrAllocator & > StringInitCodePool
Definition: Record.cpp:75
llvm::StringInit::getFormat
StringFormat getFormat() const
Definition: Record.h:668
llvm::BinOpInit::LE
@ LE
Definition: Record.h:854
llvm::StringRef::str
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:221
llvm::StringInit::StringFormat
StringFormat
Definition: Record.h:640
llvm::RecordResolver
Resolve all variables from a record except for unset variables.
Definition: Record.h:2187
llvm::StringInit::getAsUnquotedString
std::string getAsUnquotedString() const override
Convert this value to a literal form, without adding quotes around a string.
Definition: Record.h:682
llvm::StringRef::find
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:281
llvm::DagInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:2299
llvm::UnOpInit::resolveReferences
Init * resolveReferences(Resolver &R) const override
This function is used by classes that refer to other variables which may not be defined at the time t...
Definition: Record.cpp:892
ForeachDagApply
static Init * ForeachDagApply(Init *LHS, DagInit *MHSd, Init *RHS, Record *CurRec)
Definition: Record.cpp:1286
llvm::BinOpInit::CONCAT
@ CONCAT
Definition: Record.h:851
llvm::VarDefInit::get
static VarDefInit * get(Record *Class, ArrayRef< Init * > Args)
Definition: Record.cpp:1940
llvm::BitsInit
'{ a, b, c }' - Represents an initializer for a BitsRecTy value.
Definition: Record.h:527
StringMap.h
llvm::VarListElementInit
List[4] - Represent access to one element of a var or field.
Definition: Record.h:1230
llvm::VarInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1841
llvm::OptimizedStructLayoutField
A field in a structure.
Definition: OptimizedStructLayout.h:45
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
llvm::VarDefInit::Fold
Init * Fold() const
Definition: Record.cpp:2035
llvm::RecTy::IntRecTyKind
@ IntRecTyKind
Definition: Record.h:63
llvm::RecordKeeper::getDef
Record * getDef(StringRef Name) const
Get the concrete record with the specified name.
Definition: Record.h:1918
llvm::UnOpInit::getOpcode
UnaryOp getOpcode() const
Definition: Record.h:821
raw_ostream.h
llvm::ExistsOpInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:1696
llvm::RecordVal
This class represents a field in a record, including its name, type, value, and source location.
Definition: Record.h:1485
llvm::IntRecTy::typeIsConvertibleTo
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Definition: Record.cpp:163
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:649
llvm::RecordRecTy::isSubClassOf
bool isSubClassOf(Record *Class) const
Definition: Record.cpp:276
llvm::detail::RecordKeeperImpl::TheIntInitPool
std::map< int64_t, IntInit * > TheIntInitPool
Definition: Record.cpp:73
llvm::VarDefInit
classname<targs...> - Represent an uninstantiated anonymous class instantiation.
Definition: Record.h:1297
llvm::RecordRecTy::typeIsConvertibleTo
bool typeIsConvertibleTo(const RecTy *RHS) const override
Return true if all values of 'this' type can be converted to the specified type.
Definition: Record.cpp:283
llvm::DagInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:2288
llvm::Record::getValueAsOptionalString
llvm::Optional< StringRef > getValueAsOptionalString(StringRef FieldName) const
This method looks up the specified field and returns its value as a string, throwing an exception if ...
Definition: Record.cpp:2629
llvm::BitRecTy::get
static BitRecTy * get(RecordKeeper &RK)
Definition: Record.cpp:120
llvm::RecordKeeper::dump
void dump() const
Definition: Record.cpp:2826
llvm::IntRecTy::get
static IntRecTy * get(RecordKeeper &RK)
Definition: Record.cpp:159
Record.h
llvm::Record::setName
void setName(Init *Name)
Definition: Record.cpp:2474
llvm::Record::hasDirectSuperClass
bool hasDirectSuperClass(const Record *SuperClass) const
Determine whether this record has the specified direct superclass.
Definition: Record.cpp:2495
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::TypedInit::convertInitListSlice
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This function is used to implement the list slice selection operator.
Definition: Record.cpp:1807
llvm::ExistsOpInit::Fold
Init * Fold(Record *CurRec, bool IsFinal=false) const
Definition: Record.cpp:1700
llvm::ListInit::getElement
Init * getElement(unsigned i) const
Definition: Record.h:718
llvm::DefInit::get
static DefInit * get(Record *)
Definition: Record.cpp:1907
llvm::BinOpInit::Profile
void Profile(FoldingSetNodeID &ID) const
Definition: Record.cpp:938
llvm::StringInit::get
static StringInit * get(RecordKeeper &RK, StringRef, StringFormat Fmt=SF_String)
Definition: Record.cpp:596
llvm::VarDefInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:2048
llvm::ArrayRef::end
iterator end() const
Definition: ArrayRef.h:153
llvm::FoldingSetBase::Node::Node
Node()=default
llvm::Record::getValueAsDef
Record * getValueAsDef(StringRef FieldName) const
This method looks up the specified field and returns its value as a Record, throwing an exception if ...
Definition: Record.cpp:2728
llvm::detail::RecordKeeperImpl::SharedDagRecTy
DagRecTy SharedDagRecTy
Definition: Record.cpp:65
llvm::detail::RecordKeeperImpl::AnyRecord
RecordRecTy AnyRecord
Definition: Record.cpp:67
llvm::UnsetInit::get
static UnsetInit * get(RecordKeeper &RK)
Get the singleton unset Init.
Definition: Record.cpp:359
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:923
ConcatStringInits
static StringInit * ConcatStringInits(const StringInit *I0, const StringInit *I1)
Definition: Record.cpp:942
llvm::AnonymousNameInit::get
static AnonymousNameInit * get(RecordKeeper &RK, unsigned)
Definition: Record.cpp:574
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::TypedInit
This is the common superclass of types that have a specific, explicit type, stored in ValueTy.
Definition: Record.h:421
llvm::FoldOpInit::getBit
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1603
INT64_MIN
#define INT64_MIN
Definition: DataTypes.h:74
llvm::VarListElementInit::getAsString
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1881