LLVM 17.0.0git
Record.h
Go to the documentation of this file.
1//===- llvm/TableGen/Record.h - Classes for Table Records -------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the main TableGen data structures, including the TableGen
10// types, values, and high-level data structures.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_TABLEGEN_RECORD_H
15#define LLVM_TABLEGEN_RECORD_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/DenseSet.h"
20#include "llvm/ADT/FoldingSet.h"
24#include "llvm/ADT/StringRef.h"
27#include "llvm/Support/SMLoc.h"
28#include "llvm/Support/Timer.h"
31#include <cassert>
32#include <cstddef>
33#include <cstdint>
34#include <map>
35#include <memory>
36#include <optional>
37#include <string>
38#include <utility>
39#include <vector>
40
41namespace llvm {
42namespace detail {
43struct RecordKeeperImpl;
44} // namespace detail
45
46class ListRecTy;
47class Record;
48class RecordKeeper;
49class RecordVal;
50class Resolver;
51class StringInit;
52class TypedInit;
53
54//===----------------------------------------------------------------------===//
55// Type Classes
56//===----------------------------------------------------------------------===//
57
58class RecTy {
59public:
60 /// Subclass discriminator (for dyn_cast<> et al.)
61 enum RecTyKind {
69 };
70
71private:
72 RecTyKind Kind;
73 /// The RecordKeeper that uniqued this Type.
74 RecordKeeper &RK;
75 /// ListRecTy of the list that has elements of this type.
76 ListRecTy *ListTy = nullptr;
77
78public:
79 RecTy(RecTyKind K, RecordKeeper &RK) : Kind(K), RK(RK) {}
80 virtual ~RecTy() = default;
81
82 RecTyKind getRecTyKind() const { return Kind; }
83
84 /// Return the RecordKeeper that uniqued this Type.
85 RecordKeeper &getRecordKeeper() const { return RK; }
86
87 virtual std::string getAsString() const = 0;
88 void print(raw_ostream &OS) const { OS << getAsString(); }
89 void dump() const;
90
91 /// Return true if all values of 'this' type can be converted to the specified
92 /// type.
93 virtual bool typeIsConvertibleTo(const RecTy *RHS) const;
94
95 /// Return true if 'this' type is equal to or a subtype of RHS. For example,
96 /// a bit set is not an int, but they are convertible.
97 virtual bool typeIsA(const RecTy *RHS) const;
98
99 /// Returns the type representing list<thistype>.
101};
102
103inline raw_ostream &operator<<(raw_ostream &OS, const RecTy &Ty) {
104 Ty.print(OS);
105 return OS;
106}
107
108/// 'bit' - Represent a single bit
109class BitRecTy : public RecTy {
111
113
114public:
115 static bool classof(const RecTy *RT) {
116 return RT->getRecTyKind() == BitRecTyKind;
117 }
118
119 static BitRecTy *get(RecordKeeper &RK);
120
121 std::string getAsString() const override { return "bit"; }
122
123 bool typeIsConvertibleTo(const RecTy *RHS) const override;
124};
125
126/// 'bits<n>' - Represent a fixed number of bits
127class BitsRecTy : public RecTy {
128 unsigned Size;
129
130 explicit BitsRecTy(RecordKeeper &RK, unsigned Sz)
131 : RecTy(BitsRecTyKind, RK), Size(Sz) {}
132
133public:
134 static bool classof(const RecTy *RT) {
135 return RT->getRecTyKind() == BitsRecTyKind;
136 }
137
138 static BitsRecTy *get(RecordKeeper &RK, unsigned Sz);
139
140 unsigned getNumBits() const { return Size; }
141
142 std::string getAsString() const override;
143
144 bool typeIsConvertibleTo(const RecTy *RHS) const override;
145
146 bool typeIsA(const RecTy *RHS) const override;
147};
148
149/// 'int' - Represent an integer value of no particular size
150class IntRecTy : public RecTy {
152
154
155public:
156 static bool classof(const RecTy *RT) {
157 return RT->getRecTyKind() == IntRecTyKind;
158 }
159
160 static IntRecTy *get(RecordKeeper &RK);
161
162 std::string getAsString() const override { return "int"; }
163
164 bool typeIsConvertibleTo(const RecTy *RHS) const override;
165};
166
167/// 'string' - Represent an string value
168class StringRecTy : public RecTy {
170
172
173public:
174 static bool classof(const RecTy *RT) {
175 return RT->getRecTyKind() == StringRecTyKind;
176 }
177
178 static StringRecTy *get(RecordKeeper &RK);
179
180 std::string getAsString() const override;
181
182 bool typeIsConvertibleTo(const RecTy *RHS) const override;
183};
184
185/// 'list<Ty>' - Represent a list of element values, all of which must be of
186/// the specified type. The type is stored in ElementTy.
187class ListRecTy : public RecTy {
189
190 RecTy *ElementTy;
191
192 explicit ListRecTy(RecTy *T)
193 : RecTy(ListRecTyKind, T->getRecordKeeper()), ElementTy(T) {}
194
195public:
196 static bool classof(const RecTy *RT) {
197 return RT->getRecTyKind() == ListRecTyKind;
198 }
199
200 static ListRecTy *get(RecTy *T) { return T->getListTy(); }
201 RecTy *getElementType() const { return ElementTy; }
202
203 std::string getAsString() const override;
204
205 bool typeIsConvertibleTo(const RecTy *RHS) const override;
206
207 bool typeIsA(const RecTy *RHS) const override;
208};
209
210/// 'dag' - Represent a dag fragment
211class DagRecTy : public RecTy {
213
215
216public:
217 static bool classof(const RecTy *RT) {
218 return RT->getRecTyKind() == DagRecTyKind;
219 }
220
221 static DagRecTy *get(RecordKeeper &RK);
222
223 std::string getAsString() const override;
224};
225
226/// '[classname]' - Type of record values that have zero or more superclasses.
227///
228/// The list of superclasses is non-redundant, i.e. only contains classes that
229/// are not the superclass of some other listed class.
230class RecordRecTy final : public RecTy, public FoldingSetNode,
231 public TrailingObjects<RecordRecTy, Record *> {
232 friend class Record;
234
235 unsigned NumClasses;
236
237 explicit RecordRecTy(RecordKeeper &RK, unsigned Num)
238 : RecTy(RecordRecTyKind, RK), NumClasses(Num) {}
239
240public:
241 RecordRecTy(const RecordRecTy &) = delete;
243
244 // Do not use sized deallocation due to trailing objects.
245 void operator delete(void *p) { ::operator delete(p); }
246
247 static bool classof(const RecTy *RT) {
248 return RT->getRecTyKind() == RecordRecTyKind;
249 }
250
251 /// Get the record type with the given non-redundant list of superclasses.
252 static RecordRecTy *get(RecordKeeper &RK, ArrayRef<Record *> Classes);
253 static RecordRecTy *get(Record *Class);
254
255 void Profile(FoldingSetNodeID &ID) const;
256
258 return ArrayRef(getTrailingObjects<Record *>(), NumClasses);
259 }
260
261 using const_record_iterator = Record * const *;
262
263 const_record_iterator classes_begin() const { return getClasses().begin(); }
264 const_record_iterator classes_end() const { return getClasses().end(); }
265
266 std::string getAsString() const override;
267
268 bool isSubClassOf(Record *Class) const;
269 bool typeIsConvertibleTo(const RecTy *RHS) const override;
270
271 bool typeIsA(const RecTy *RHS) const override;
272};
273
274/// Find a common type that T1 and T2 convert to.
275/// Return 0 if no such type exists.
276RecTy *resolveTypes(RecTy *T1, RecTy *T2);
277
278//===----------------------------------------------------------------------===//
279// Initializer Classes
280//===----------------------------------------------------------------------===//
281
282class Init {
283protected:
284 /// Discriminator enum (for isa<>, dyn_cast<>, et al.)
285 ///
286 /// This enum is laid out by a preorder traversal of the inheritance
287 /// hierarchy, and does not contain an entry for abstract classes, as per
288 /// the recommendation in docs/HowToSetUpLLVMStyleRTTI.rst.
289 ///
290 /// We also explicitly include "first" and "last" values for each
291 /// interior node of the inheritance tree, to make it easier to read the
292 /// corresponding classof().
293 ///
294 /// We could pack these a bit tighter by not having the IK_FirstXXXInit
295 /// and IK_LastXXXInit be their own values, but that would degrade
296 /// readability for really no benefit.
297 enum InitKind : uint8_t {
298 IK_First, // unused; silence a spurious warning
324 };
325
326private:
327 const InitKind Kind;
328
329protected:
330 uint8_t Opc; // Used by UnOpInit, BinOpInit, and TernOpInit
331
332private:
333 virtual void anchor();
334
335public:
336 /// Get the kind (type) of the value.
337 InitKind getKind() const { return Kind; }
338
339 /// Get the record keeper that initialized this Init.
341
342protected:
343 explicit Init(InitKind K, uint8_t Opc = 0) : Kind(K), Opc(Opc) {}
344
345public:
346 Init(const Init &) = delete;
347 Init &operator=(const Init &) = delete;
348 virtual ~Init() = default;
349
350 /// Is this a complete value with no unset (uninitialized) subvalues?
351 virtual bool isComplete() const { return true; }
352
353 /// Is this a concrete and fully resolved value without any references or
354 /// stuck operations? Unset values are concrete.
355 virtual bool isConcrete() const { return false; }
356
357 /// Print this value.
358 void print(raw_ostream &OS) const { OS << getAsString(); }
359
360 /// Convert this value to a literal form.
361 virtual std::string getAsString() const = 0;
362
363 /// Convert this value to a literal form,
364 /// without adding quotes around a string.
365 virtual std::string getAsUnquotedString() const { return getAsString(); }
366
367 /// Debugging method that may be called through a debugger; just
368 /// invokes print on stderr.
369 void dump() const;
370
371 /// If this value is convertible to type \p Ty, return a value whose
372 /// type is \p Ty, generating a !cast operation if required.
373 /// Otherwise, return null.
374 virtual Init *getCastTo(RecTy *Ty) const = 0;
375
376 /// Convert to a value whose type is \p Ty, or return null if this
377 /// is not possible. This can happen if the value's type is convertible
378 /// to \p Ty, but there are unresolved references.
379 virtual Init *convertInitializerTo(RecTy *Ty) const = 0;
380
381 /// This function is used to implement the bit range
382 /// selection operator. Given a value, it selects the specified bits,
383 /// returning them as a new \p Init of type \p bits. If it is not legal
384 /// to use the bit selection operator on this value, null is returned.
386 return nullptr;
387 }
388
389 /// This function is used to implement the list slice
390 /// selection operator. Given a value, it selects the specified list
391 /// elements, returning them as a new \p Init of type \p list. If it
392 /// is not legal to use the slice operator, null is returned.
394 return nullptr;
395 }
396
397 /// This function is used to implement the FieldInit class.
398 /// Implementors of this method should return the type of the named
399 /// field if they are of type record.
400 virtual RecTy *getFieldType(StringInit *FieldName) const {
401 return nullptr;
402 }
403
404 /// This function is used by classes that refer to other
405 /// variables which may not be defined at the time the expression is formed.
406 /// If a value is set for the variable later, this method will be called on
407 /// users of the value to allow the value to propagate out.
408 virtual Init *resolveReferences(Resolver &R) const {
409 return const_cast<Init *>(this);
410 }
411
412 /// Get the \p Init value of the specified bit.
413 virtual Init *getBit(unsigned Bit) const = 0;
414};
415
417 I.print(OS); return OS;
418}
419
420/// This is the common superclass of types that have a specific,
421/// explicit type, stored in ValueTy.
422class TypedInit : public Init {
423 RecTy *ValueTy;
424
425protected:
426 explicit TypedInit(InitKind K, RecTy *T, uint8_t Opc = 0)
427 : Init(K, Opc), ValueTy(T) {}
428
429public:
430 TypedInit(const TypedInit &) = delete;
431 TypedInit &operator=(const TypedInit &) = delete;
432
433 static bool classof(const Init *I) {
434 return I->getKind() >= IK_FirstTypedInit &&
435 I->getKind() <= IK_LastTypedInit;
436 }
437
438 /// Get the type of the Init as a RecTy.
439 RecTy *getType() const { return ValueTy; }
440
441 /// Get the record keeper that initialized this Init.
442 RecordKeeper &getRecordKeeper() const { return ValueTy->getRecordKeeper(); }
443
444 Init *getCastTo(RecTy *Ty) const override;
445 Init *convertInitializerTo(RecTy *Ty) const override;
446
448 Init *convertInitListSlice(ArrayRef<unsigned> Elements) const override;
449
450 /// This method is used to implement the FieldInit class.
451 /// Implementors of this method should return the type of the named field if
452 /// they are of type record.
453 RecTy *getFieldType(StringInit *FieldName) const override;
454};
455
456/// '?' - Represents an uninitialized value.
457class UnsetInit : public Init {
459
460 /// The record keeper that initialized this Init.
461 RecordKeeper &RK;
462
463 UnsetInit(RecordKeeper &RK) : Init(IK_UnsetInit), RK(RK) {}
464
465public:
466 UnsetInit(const UnsetInit &) = delete;
467 UnsetInit &operator=(const UnsetInit &) = delete;
468
469 static bool classof(const Init *I) {
470 return I->getKind() == IK_UnsetInit;
471 }
472
473 /// Get the singleton unset Init.
474 static UnsetInit *get(RecordKeeper &RK);
475
476 /// Get the record keeper that initialized this Init.
477 RecordKeeper &getRecordKeeper() const { return RK; }
478
479 Init *getCastTo(RecTy *Ty) const override;
480 Init *convertInitializerTo(RecTy *Ty) const override;
481
482 Init *getBit(unsigned Bit) const override {
483 return const_cast<UnsetInit*>(this);
484 }
485
486 /// Is this a complete value with no unset (uninitialized) subvalues?
487 bool isComplete() const override { return false; }
488
489 bool isConcrete() const override { return true; }
490
491 /// Get the string representation of the Init.
492 std::string getAsString() const override { return "?"; }
493};
494
495/// 'true'/'false' - Represent a concrete initializer for a bit.
496class BitInit final : public TypedInit {
498
499 bool Value;
500
501 explicit BitInit(bool V, RecTy *T) : TypedInit(IK_BitInit, T), Value(V) {}
502
503public:
504 BitInit(const BitInit &) = delete;
506
507 static bool classof(const Init *I) {
508 return I->getKind() == IK_BitInit;
509 }
510
511 static BitInit *get(RecordKeeper &RK, bool V);
512
513 bool getValue() const { return Value; }
514
515 Init *convertInitializerTo(RecTy *Ty) const override;
516
517 Init *getBit(unsigned Bit) const override {
518 assert(Bit < 1 && "Bit index out of range!");
519 return const_cast<BitInit*>(this);
520 }
521
522 bool isConcrete() const override { return true; }
523 std::string getAsString() const override { return Value ? "1" : "0"; }
524};
525
526/// '{ a, b, c }' - Represents an initializer for a BitsRecTy value.
527/// It contains a vector of bits, whose size is determined by the type.
528class BitsInit final : public TypedInit, public FoldingSetNode,
529 public TrailingObjects<BitsInit, Init *> {
530 unsigned NumBits;
531
532 BitsInit(RecordKeeper &RK, unsigned N)
533 : TypedInit(IK_BitsInit, BitsRecTy::get(RK, N)), NumBits(N) {}
534
535public:
536 BitsInit(const BitsInit &) = delete;
537 BitsInit &operator=(const BitsInit &) = delete;
538
539 // Do not use sized deallocation due to trailing objects.
540 void operator delete(void *p) { ::operator delete(p); }
541
542 static bool classof(const Init *I) {
543 return I->getKind() == IK_BitsInit;
544 }
545
546 static BitsInit *get(RecordKeeper &RK, ArrayRef<Init *> Range);
547
548 void Profile(FoldingSetNodeID &ID) const;
549
550 unsigned getNumBits() const { return NumBits; }
551
552 Init *convertInitializerTo(RecTy *Ty) const override;
554
555 bool isComplete() const override {
556 for (unsigned i = 0; i != getNumBits(); ++i)
557 if (!getBit(i)->isComplete()) return false;
558 return true;
559 }
560
561 bool allInComplete() const {
562 for (unsigned i = 0; i != getNumBits(); ++i)
563 if (getBit(i)->isComplete()) return false;
564 return true;
565 }
566
567 bool isConcrete() const override;
568 std::string getAsString() const override;
569
570 Init *resolveReferences(Resolver &R) const override;
571
572 Init *getBit(unsigned Bit) const override {
573 assert(Bit < NumBits && "Bit index out of range!");
574 return getTrailingObjects<Init *>()[Bit];
575 }
576};
577
578/// '7' - Represent an initialization by a literal integer value.
579class IntInit : public TypedInit {
580 int64_t Value;
581
582 explicit IntInit(RecordKeeper &RK, int64_t V)
584
585public:
586 IntInit(const IntInit &) = delete;
587 IntInit &operator=(const IntInit &) = delete;
588
589 static bool classof(const Init *I) {
590 return I->getKind() == IK_IntInit;
591 }
592
593 static IntInit *get(RecordKeeper &RK, int64_t V);
594
595 int64_t getValue() const { return Value; }
596
597 Init *convertInitializerTo(RecTy *Ty) const override;
599
600 bool isConcrete() const override { return true; }
601 std::string getAsString() const override;
602
603 Init *getBit(unsigned Bit) const override {
604 return BitInit::get(getRecordKeeper(), (Value & (1ULL << Bit)) != 0);
605 }
606};
607
608/// "anonymous_n" - Represent an anonymous record name
610 unsigned Value;
611
612 explicit AnonymousNameInit(RecordKeeper &RK, unsigned V)
614
615public:
618
619 static bool classof(const Init *I) {
620 return I->getKind() == IK_AnonymousNameInit;
621 }
622
623 static AnonymousNameInit *get(RecordKeeper &RK, unsigned);
624
625 unsigned getValue() const { return Value; }
626
627 StringInit *getNameInit() const;
628
629 std::string getAsString() const override;
630
631 Init *resolveReferences(Resolver &R) const override;
632
633 Init *getBit(unsigned Bit) const override {
634 llvm_unreachable("Illegal bit reference off string");
635 }
636};
637
638/// "foo" - Represent an initialization by a string value.
639class StringInit : public TypedInit {
640public:
642 SF_String, // Format as "text"
643 SF_Code, // Format as [{text}]
644 };
645
646private:
648 StringFormat Format;
649
650 explicit StringInit(RecordKeeper &RK, StringRef V, StringFormat Fmt)
651 : TypedInit(IK_StringInit, StringRecTy::get(RK)), Value(V), Format(Fmt) {}
652
653public:
654 StringInit(const StringInit &) = delete;
655 StringInit &operator=(const StringInit &) = delete;
656
657 static bool classof(const Init *I) {
658 return I->getKind() == IK_StringInit;
659 }
660
662 StringFormat Fmt = SF_String);
663
665 return (Fmt1 == SF_Code || Fmt2 == SF_Code) ? SF_Code : SF_String;
666 }
667
668 StringRef getValue() const { return Value; }
669 StringFormat getFormat() const { return Format; }
670 bool hasCodeFormat() const { return Format == SF_Code; }
671
672 Init *convertInitializerTo(RecTy *Ty) const override;
673
674 bool isConcrete() const override { return true; }
675
676 std::string getAsString() const override {
677 if (Format == SF_String)
678 return "\"" + Value.str() + "\"";
679 else
680 return "[{" + Value.str() + "}]";
681 }
682
683 std::string getAsUnquotedString() const override {
684 return std::string(Value);
685 }
686
687 Init *getBit(unsigned Bit) const override {
688 llvm_unreachable("Illegal bit reference off string");
689 }
690};
691
692/// [AL, AH, CL] - Represent a list of defs
693///
694class ListInit final : public TypedInit, public FoldingSetNode,
695 public TrailingObjects<ListInit, Init *> {
696 unsigned NumValues;
697
698public:
699 using const_iterator = Init *const *;
700
701private:
702 explicit ListInit(unsigned N, RecTy *EltTy)
703 : TypedInit(IK_ListInit, ListRecTy::get(EltTy)), NumValues(N) {}
704
705public:
706 ListInit(const ListInit &) = delete;
707 ListInit &operator=(const ListInit &) = delete;
708
709 // Do not use sized deallocation due to trailing objects.
710 void operator delete(void *p) { ::operator delete(p); }
711
712 static bool classof(const Init *I) {
713 return I->getKind() == IK_ListInit;
714 }
715 static ListInit *get(ArrayRef<Init *> Range, RecTy *EltTy);
716
717 void Profile(FoldingSetNodeID &ID) const;
718
719 Init *getElement(unsigned i) const {
720 assert(i < NumValues && "List element index out of range!");
721 return getTrailingObjects<Init *>()[i];
722 }
724 return cast<ListRecTy>(getType())->getElementType();
725 }
726
727 Record *getElementAsRecord(unsigned i) const;
728
729 Init *convertInitListSlice(ArrayRef<unsigned> Elements) const override;
730
731 Init *convertInitializerTo(RecTy *Ty) const override;
732
733 /// This method is used by classes that refer to other
734 /// variables which may not be defined at the time they expression is formed.
735 /// If a value is set for the variable later, this method will be called on
736 /// users of the value to allow the value to propagate out.
737 ///
738 Init *resolveReferences(Resolver &R) const override;
739
740 bool isComplete() const override;
741 bool isConcrete() const override;
742 std::string getAsString() const override;
743
745 return ArrayRef(getTrailingObjects<Init *>(), NumValues);
746 }
747
748 const_iterator begin() const { return getTrailingObjects<Init *>(); }
749 const_iterator end () const { return begin() + NumValues; }
750
751 size_t size () const { return NumValues; }
752 bool empty() const { return NumValues == 0; }
753
754 Init *getBit(unsigned Bit) const override {
755 llvm_unreachable("Illegal bit reference off list");
756 }
757};
758
759/// Base class for operators
760///
761class OpInit : public TypedInit {
762protected:
763 explicit OpInit(InitKind K, RecTy *Type, uint8_t Opc)
764 : TypedInit(K, Type, Opc) {}
765
766public:
767 OpInit(const OpInit &) = delete;
768 OpInit &operator=(OpInit &) = delete;
769
770 static bool classof(const Init *I) {
771 return I->getKind() >= IK_FirstOpInit &&
772 I->getKind() <= IK_LastOpInit;
773 }
774
775 // Clone - Clone this operator, replacing arguments with the new list
777
778 virtual unsigned getNumOperands() const = 0;
779 virtual Init *getOperand(unsigned i) const = 0;
780
781 Init *getBit(unsigned Bit) const override;
782};
783
784/// !op (X) - Transform an init.
785///
786class UnOpInit : public OpInit, public FoldingSetNode {
787public:
788 enum UnaryOp : uint8_t { CAST, NOT, HEAD, TAIL, SIZE, EMPTY, GETDAGOP, LOG2 };
789
790private:
791 Init *LHS;
792
793 UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type)
794 : OpInit(IK_UnOpInit, Type, opc), LHS(lhs) {}
795
796public:
797 UnOpInit(const UnOpInit &) = delete;
798 UnOpInit &operator=(const UnOpInit &) = delete;
799
800 static bool classof(const Init *I) {
801 return I->getKind() == IK_UnOpInit;
802 }
803
804 static UnOpInit *get(UnaryOp opc, Init *lhs, RecTy *Type);
805
806 void Profile(FoldingSetNodeID &ID) const;
807
808 // Clone - Clone this operator, replacing arguments with the new list
810 assert(Operands.size() == 1 &&
811 "Wrong number of operands for unary operation");
812 return UnOpInit::get(getOpcode(), *Operands.begin(), getType());
813 }
814
815 unsigned getNumOperands() const override { return 1; }
816
817 Init *getOperand(unsigned i) const override {
818 assert(i == 0 && "Invalid operand id for unary operator");
819 return getOperand();
820 }
821
822 UnaryOp getOpcode() const { return (UnaryOp)Opc; }
823 Init *getOperand() const { return LHS; }
824
825 // Fold - If possible, fold this to a simpler init. Return this if not
826 // possible to fold.
827 Init *Fold(Record *CurRec, bool IsFinal = false) const;
828
829 Init *resolveReferences(Resolver &R) const override;
830
831 std::string getAsString() const override;
832};
833
834/// !op (X, Y) - Combine two inits.
835class BinOpInit : public OpInit, public FoldingSetNode {
836public:
837 enum BinaryOp : uint8_t {
861 };
862
863private:
864 Init *LHS, *RHS;
865
866 BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) :
867 OpInit(IK_BinOpInit, Type, opc), LHS(lhs), RHS(rhs) {}
868
869public:
870 BinOpInit(const BinOpInit &) = delete;
871 BinOpInit &operator=(const BinOpInit &) = delete;
872
873 static bool classof(const Init *I) {
874 return I->getKind() == IK_BinOpInit;
875 }
876
877 static BinOpInit *get(BinaryOp opc, Init *lhs, Init *rhs,
878 RecTy *Type);
879 static Init *getStrConcat(Init *lhs, Init *rhs);
880 static Init *getListConcat(TypedInit *lhs, Init *rhs);
881
882 void Profile(FoldingSetNodeID &ID) const;
883
884 // Clone - Clone this operator, replacing arguments with the new list
886 assert(Operands.size() == 2 &&
887 "Wrong number of operands for binary operation");
888 return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType());
889 }
890
891 unsigned getNumOperands() const override { return 2; }
892 Init *getOperand(unsigned i) const override {
893 switch (i) {
894 default: llvm_unreachable("Invalid operand id for binary operator");
895 case 0: return getLHS();
896 case 1: return getRHS();
897 }
898 }
899
900 BinaryOp getOpcode() const { return (BinaryOp)Opc; }
901 Init *getLHS() const { return LHS; }
902 Init *getRHS() const { return RHS; }
903
904 std::optional<bool> CompareInit(unsigned Opc, Init *LHS, Init *RHS) const;
905
906 // Fold - If possible, fold this to a simpler init. Return this if not
907 // possible to fold.
908 Init *Fold(Record *CurRec) const;
909
910 Init *resolveReferences(Resolver &R) const override;
911
912 std::string getAsString() const override;
913};
914
915/// !op (X, Y, Z) - Combine two inits.
916class TernOpInit : public OpInit, public FoldingSetNode {
917public:
918 enum TernaryOp : uint8_t { SUBST, FOREACH, FILTER, IF, DAG, SUBSTR, FIND };
919
920private:
921 Init *LHS, *MHS, *RHS;
922
923 TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs,
924 RecTy *Type) :
925 OpInit(IK_TernOpInit, Type, opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
926
927public:
928 TernOpInit(const TernOpInit &) = delete;
929 TernOpInit &operator=(const TernOpInit &) = delete;
930
931 static bool classof(const Init *I) {
932 return I->getKind() == IK_TernOpInit;
933 }
934
935 static TernOpInit *get(TernaryOp opc, Init *lhs,
936 Init *mhs, Init *rhs,
937 RecTy *Type);
938
939 void Profile(FoldingSetNodeID &ID) const;
940
941 // Clone - Clone this operator, replacing arguments with the new list
943 assert(Operands.size() == 3 &&
944 "Wrong number of operands for ternary operation");
946 getType());
947 }
948
949 unsigned getNumOperands() const override { return 3; }
950 Init *getOperand(unsigned i) const override {
951 switch (i) {
952 default: llvm_unreachable("Invalid operand id for ternary operator");
953 case 0: return getLHS();
954 case 1: return getMHS();
955 case 2: return getRHS();
956 }
957 }
958
959 TernaryOp getOpcode() const { return (TernaryOp)Opc; }
960 Init *getLHS() const { return LHS; }
961 Init *getMHS() const { return MHS; }
962 Init *getRHS() const { return RHS; }
963
964 // Fold - If possible, fold this to a simpler init. Return this if not
965 // possible to fold.
966 Init *Fold(Record *CurRec) const;
967
968 bool isComplete() const override {
969 return LHS->isComplete() && MHS->isComplete() && RHS->isComplete();
970 }
971
972 Init *resolveReferences(Resolver &R) const override;
973
974 std::string getAsString() const override;
975};
976
977/// !cond(condition_1: value1, ... , condition_n: value)
978/// Selects the first value for which condition is true.
979/// Otherwise reports an error.
980class CondOpInit final : public TypedInit, public FoldingSetNode,
981 public TrailingObjects<CondOpInit, Init *> {
982 unsigned NumConds;
983 RecTy *ValType;
984
985 CondOpInit(unsigned NC, RecTy *Type)
987 NumConds(NC), ValType(Type) {}
988
989 size_t numTrailingObjects(OverloadToken<Init *>) const {
990 return 2*NumConds;
991 }
992
993public:
994 CondOpInit(const CondOpInit &) = delete;
995 CondOpInit &operator=(const CondOpInit &) = delete;
996
997 static bool classof(const Init *I) {
998 return I->getKind() == IK_CondOpInit;
999 }
1000
1002 RecTy *Type);
1003
1004 void Profile(FoldingSetNodeID &ID) const;
1005
1006 RecTy *getValType() const { return ValType; }
1007
1008 unsigned getNumConds() const { return NumConds; }
1009
1010 Init *getCond(unsigned Num) const {
1011 assert(Num < NumConds && "Condition number out of range!");
1012 return getTrailingObjects<Init *>()[Num];
1013 }
1014
1015 Init *getVal(unsigned Num) const {
1016 assert(Num < NumConds && "Val number out of range!");
1017 return getTrailingObjects<Init *>()[Num+NumConds];
1018 }
1019
1021 return ArrayRef(getTrailingObjects<Init *>(), NumConds);
1022 }
1023
1025 return ArrayRef(getTrailingObjects<Init *>() + NumConds, NumConds);
1026 }
1027
1028 Init *Fold(Record *CurRec) const;
1029
1030 Init *resolveReferences(Resolver &R) const override;
1031
1032 bool isConcrete() const override;
1033 bool isComplete() const override;
1034 std::string getAsString() const override;
1035
1038
1039 inline const_case_iterator arg_begin() const { return getConds().begin(); }
1040 inline const_case_iterator arg_end () const { return getConds().end(); }
1041
1042 inline size_t case_size () const { return NumConds; }
1043 inline bool case_empty() const { return NumConds == 0; }
1044
1045 inline const_val_iterator name_begin() const { return getVals().begin();}
1046 inline const_val_iterator name_end () const { return getVals().end(); }
1047
1048 inline size_t val_size () const { return NumConds; }
1049 inline bool val_empty() const { return NumConds == 0; }
1050
1051 Init *getBit(unsigned Bit) const override;
1052};
1053
1054/// !foldl (a, b, expr, start, lst) - Fold over a list.
1055class FoldOpInit : public TypedInit, public FoldingSetNode {
1056private:
1057 Init *Start;
1058 Init *List;
1059 Init *A;
1060 Init *B;
1061 Init *Expr;
1062
1063 FoldOpInit(Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
1064 : TypedInit(IK_FoldOpInit, Type), Start(Start), List(List), A(A), B(B),
1065 Expr(Expr) {}
1066
1067public:
1068 FoldOpInit(const FoldOpInit &) = delete;
1069 FoldOpInit &operator=(const FoldOpInit &) = delete;
1070
1071 static bool classof(const Init *I) { return I->getKind() == IK_FoldOpInit; }
1072
1073 static FoldOpInit *get(Init *Start, Init *List, Init *A, Init *B, Init *Expr,
1074 RecTy *Type);
1075
1076 void Profile(FoldingSetNodeID &ID) const;
1077
1078 // Fold - If possible, fold this to a simpler init. Return this if not
1079 // possible to fold.
1080 Init *Fold(Record *CurRec) const;
1081
1082 bool isComplete() const override { return false; }
1083
1084 Init *resolveReferences(Resolver &R) const override;
1085
1086 Init *getBit(unsigned Bit) const override;
1087
1088 std::string getAsString() const override;
1089};
1090
1091/// !isa<type>(expr) - Dynamically determine the type of an expression.
1092class IsAOpInit : public TypedInit, public FoldingSetNode {
1093private:
1094 RecTy *CheckType;
1095 Init *Expr;
1096
1097 IsAOpInit(RecTy *CheckType, Init *Expr)
1099 CheckType(CheckType), Expr(Expr) {}
1100
1101public:
1102 IsAOpInit(const IsAOpInit &) = delete;
1103 IsAOpInit &operator=(const IsAOpInit &) = delete;
1104
1105 static bool classof(const Init *I) { return I->getKind() == IK_IsAOpInit; }
1106
1107 static IsAOpInit *get(RecTy *CheckType, Init *Expr);
1108
1109 void Profile(FoldingSetNodeID &ID) const;
1110
1111 // Fold - If possible, fold this to a simpler init. Return this if not
1112 // possible to fold.
1113 Init *Fold() const;
1114
1115 bool isComplete() const override { return false; }
1116
1117 Init *resolveReferences(Resolver &R) const override;
1118
1119 Init *getBit(unsigned Bit) const override;
1120
1121 std::string getAsString() const override;
1122};
1123
1124/// !exists<type>(expr) - Dynamically determine if a record of `type` named
1125/// `expr` exists.
1126class ExistsOpInit : public TypedInit, public FoldingSetNode {
1127private:
1128 RecTy *CheckType;
1129 Init *Expr;
1130
1131 ExistsOpInit(RecTy *CheckType, Init *Expr)
1133 CheckType(CheckType), Expr(Expr) {}
1134
1135public:
1136 ExistsOpInit(const ExistsOpInit &) = delete;
1138
1139 static bool classof(const Init *I) { return I->getKind() == IK_ExistsOpInit; }
1140
1141 static ExistsOpInit *get(RecTy *CheckType, Init *Expr);
1142
1143 void Profile(FoldingSetNodeID &ID) const;
1144
1145 // Fold - If possible, fold this to a simpler init. Return this if not
1146 // possible to fold.
1147 Init *Fold(Record *CurRec, bool IsFinal = false) const;
1148
1149 bool isComplete() const override { return false; }
1150
1151 Init *resolveReferences(Resolver &R) const override;
1152
1153 Init *getBit(unsigned Bit) const override;
1154
1155 std::string getAsString() const override;
1156};
1157
1158/// 'Opcode' - Represent a reference to an entire variable object.
1159class VarInit : public TypedInit {
1160 Init *VarName;
1161
1162 explicit VarInit(Init *VN, RecTy *T)
1163 : TypedInit(IK_VarInit, T), VarName(VN) {}
1164
1165public:
1166 VarInit(const VarInit &) = delete;
1167 VarInit &operator=(const VarInit &) = delete;
1168
1169 static bool classof(const Init *I) {
1170 return I->getKind() == IK_VarInit;
1171 }
1172
1173 static VarInit *get(StringRef VN, RecTy *T);
1174 static VarInit *get(Init *VN, RecTy *T);
1175
1176 StringRef getName() const;
1177 Init *getNameInit() const { return VarName; }
1178
1179 std::string getNameInitAsString() const {
1180 return getNameInit()->getAsUnquotedString();
1181 }
1182
1183 /// This method is used by classes that refer to other
1184 /// variables which may not be defined at the time they expression is formed.
1185 /// If a value is set for the variable later, this method will be called on
1186 /// users of the value to allow the value to propagate out.
1187 ///
1188 Init *resolveReferences(Resolver &R) const override;
1189
1190 Init *getBit(unsigned Bit) const override;
1191
1192 std::string getAsString() const override { return std::string(getName()); }
1193};
1194
1195/// Opcode{0} - Represent access to one bit of a variable or field.
1196class VarBitInit final : public TypedInit {
1197 TypedInit *TI;
1198 unsigned Bit;
1199
1200 VarBitInit(TypedInit *T, unsigned B)
1201 : TypedInit(IK_VarBitInit, BitRecTy::get(T->getRecordKeeper())), TI(T),
1202 Bit(B) {
1203 assert(T->getType() &&
1204 (isa<IntRecTy>(T->getType()) ||
1205 (isa<BitsRecTy>(T->getType()) &&
1206 cast<BitsRecTy>(T->getType())->getNumBits() > B)) &&
1207 "Illegal VarBitInit expression!");
1208 }
1209
1210public:
1211 VarBitInit(const VarBitInit &) = delete;
1212 VarBitInit &operator=(const VarBitInit &) = delete;
1213
1214 static bool classof(const Init *I) {
1215 return I->getKind() == IK_VarBitInit;
1216 }
1217
1218 static VarBitInit *get(TypedInit *T, unsigned B);
1219
1220 Init *getBitVar() const { return TI; }
1221 unsigned getBitNum() const { return Bit; }
1222
1223 std::string getAsString() const override;
1224 Init *resolveReferences(Resolver &R) const override;
1225
1226 Init *getBit(unsigned B) const override {
1227 assert(B < 1 && "Bit index out of range!");
1228 return const_cast<VarBitInit*>(this);
1229 }
1230};
1231
1232/// List[4] - Represent access to one element of a var or
1233/// field.
1235 TypedInit *TI;
1236 unsigned Element;
1237
1238 VarListElementInit(TypedInit *T, unsigned E)
1240 cast<ListRecTy>(T->getType())->getElementType()),
1241 TI(T), Element(E) {
1242 assert(T->getType() && isa<ListRecTy>(T->getType()) &&
1243 "Illegal VarBitInit expression!");
1244 }
1245
1246public:
1249
1250 static bool classof(const Init *I) {
1251 return I->getKind() == IK_VarListElementInit;
1252 }
1253
1254 static VarListElementInit *get(TypedInit *T, unsigned E);
1255
1256 TypedInit *getVariable() const { return TI; }
1257 unsigned getElementNum() const { return Element; }
1258
1259 std::string getAsString() const override;
1260 Init *resolveReferences(Resolver &R) const override;
1261
1262 Init *getBit(unsigned Bit) const override;
1263};
1264
1265/// AL - Represent a reference to a 'def' in the description
1266class DefInit : public TypedInit {
1267 friend class Record;
1268
1269 Record *Def;
1270
1271 explicit DefInit(Record *D);
1272
1273public:
1274 DefInit(const DefInit &) = delete;
1275 DefInit &operator=(const DefInit &) = delete;
1276
1277 static bool classof(const Init *I) {
1278 return I->getKind() == IK_DefInit;
1279 }
1280
1281 static DefInit *get(Record*);
1282
1283 Init *convertInitializerTo(RecTy *Ty) const override;
1284
1285 Record *getDef() const { return Def; }
1286
1287 //virtual Init *convertInitializerBitRange(ArrayRef<unsigned> Bits);
1288
1289 RecTy *getFieldType(StringInit *FieldName) const override;
1290
1291 bool isConcrete() const override { return true; }
1292 std::string getAsString() const override;
1293
1294 Init *getBit(unsigned Bit) const override {
1295 llvm_unreachable("Illegal bit reference off def");
1296 }
1297};
1298
1299/// classname<targs...> - Represent an uninstantiated anonymous class
1300/// instantiation.
1301class VarDefInit final : public TypedInit, public FoldingSetNode,
1302 public TrailingObjects<VarDefInit, Init *> {
1303 Record *Class;
1304 DefInit *Def = nullptr; // after instantiation
1305 unsigned NumArgs;
1306
1307 explicit VarDefInit(Record *Class, unsigned N);
1308
1309 DefInit *instantiate();
1310
1311public:
1312 VarDefInit(const VarDefInit &) = delete;
1313 VarDefInit &operator=(const VarDefInit &) = delete;
1314
1315 // Do not use sized deallocation due to trailing objects.
1316 void operator delete(void *p) { ::operator delete(p); }
1317
1318 static bool classof(const Init *I) {
1319 return I->getKind() == IK_VarDefInit;
1320 }
1321 static VarDefInit *get(Record *Class, ArrayRef<Init *> Args);
1322
1323 void Profile(FoldingSetNodeID &ID) const;
1324
1325 Init *resolveReferences(Resolver &R) const override;
1326 Init *Fold() const;
1327
1328 std::string getAsString() const override;
1329
1330 Init *getArg(unsigned i) const {
1331 assert(i < NumArgs && "Argument index out of range!");
1332 return getTrailingObjects<Init *>()[i];
1333 }
1334
1335 using const_iterator = Init *const *;
1336
1337 const_iterator args_begin() const { return getTrailingObjects<Init *>(); }
1338 const_iterator args_end () const { return args_begin() + NumArgs; }
1339
1340 size_t args_size () const { return NumArgs; }
1341 bool args_empty() const { return NumArgs == 0; }
1342
1343 ArrayRef<Init *> args() const { return ArrayRef(args_begin(), NumArgs); }
1344
1345 Init *getBit(unsigned Bit) const override {
1346 llvm_unreachable("Illegal bit reference off anonymous def");
1347 }
1348};
1349
1350/// X.Y - Represent a reference to a subfield of a variable
1351class FieldInit : public TypedInit {
1352 Init *Rec; // Record we are referring to
1353 StringInit *FieldName; // Field we are accessing
1354
1355 FieldInit(Init *R, StringInit *FN)
1356 : TypedInit(IK_FieldInit, R->getFieldType(FN)), Rec(R), FieldName(FN) {
1357#ifndef NDEBUG
1358 if (!getType()) {
1359 llvm::errs() << "In Record = " << Rec->getAsString()
1360 << ", got FieldName = " << *FieldName
1361 << " with non-record type!\n";
1362 llvm_unreachable("FieldInit with non-record type!");
1363 }
1364#endif
1365 }
1366
1367public:
1368 FieldInit(const FieldInit &) = delete;
1369 FieldInit &operator=(const FieldInit &) = delete;
1370
1371 static bool classof(const Init *I) {
1372 return I->getKind() == IK_FieldInit;
1373 }
1374
1375 static FieldInit *get(Init *R, StringInit *FN);
1376
1377 Init *getRecord() const { return Rec; }
1378 StringInit *getFieldName() const { return FieldName; }
1379
1380 Init *getBit(unsigned Bit) const override;
1381
1382 Init *resolveReferences(Resolver &R) const override;
1383 Init *Fold(Record *CurRec) const;
1384
1385 bool isConcrete() const override;
1386 std::string getAsString() const override {
1387 return Rec->getAsString() + "." + FieldName->getValue().str();
1388 }
1389};
1390
1391/// (v a, b) - Represent a DAG tree value. DAG inits are required
1392/// to have at least one value then a (possibly empty) list of arguments. Each
1393/// argument can have a name associated with it.
1394class DagInit final : public TypedInit, public FoldingSetNode,
1395 public TrailingObjects<DagInit, Init *, StringInit *> {
1396 friend TrailingObjects;
1397
1398 Init *Val;
1399 StringInit *ValName;
1400 unsigned NumArgs;
1401 unsigned NumArgNames;
1402
1403 DagInit(Init *V, StringInit *VN, unsigned NumArgs, unsigned NumArgNames)
1405 ValName(VN), NumArgs(NumArgs), NumArgNames(NumArgNames) {}
1406
1407 size_t numTrailingObjects(OverloadToken<Init *>) const { return NumArgs; }
1408
1409public:
1410 DagInit(const DagInit &) = delete;
1411 DagInit &operator=(const DagInit &) = delete;
1412
1413 static bool classof(const Init *I) {
1414 return I->getKind() == IK_DagInit;
1415 }
1416
1417 static DagInit *get(Init *V, StringInit *VN, ArrayRef<Init *> ArgRange,
1418 ArrayRef<StringInit*> NameRange);
1419 static DagInit *get(Init *V, StringInit *VN,
1420 ArrayRef<std::pair<Init*, StringInit*>> Args);
1421
1422 void Profile(FoldingSetNodeID &ID) const;
1423
1424 Init *getOperator() const { return Val; }
1426
1427 StringInit *getName() const { return ValName; }
1428
1430 return ValName ? ValName->getValue() : StringRef();
1431 }
1432
1433 unsigned getNumArgs() const { return NumArgs; }
1434
1435 Init *getArg(unsigned Num) const {
1436 assert(Num < NumArgs && "Arg number out of range!");
1437 return getTrailingObjects<Init *>()[Num];
1438 }
1439
1440 StringInit *getArgName(unsigned Num) const {
1441 assert(Num < NumArgNames && "Arg number out of range!");
1442 return getTrailingObjects<StringInit *>()[Num];
1443 }
1444
1445 StringRef getArgNameStr(unsigned Num) const {
1446 StringInit *Init = getArgName(Num);
1447 return Init ? Init->getValue() : StringRef();
1448 }
1449
1451 return ArrayRef(getTrailingObjects<Init *>(), NumArgs);
1452 }
1453
1455 return ArrayRef(getTrailingObjects<StringInit *>(), NumArgNames);
1456 }
1457
1458 Init *resolveReferences(Resolver &R) const override;
1459
1460 bool isConcrete() const override;
1461 std::string getAsString() const override;
1462
1465
1466 inline const_arg_iterator arg_begin() const { return getArgs().begin(); }
1467 inline const_arg_iterator arg_end () const { return getArgs().end(); }
1468
1469 inline size_t arg_size () const { return NumArgs; }
1470 inline bool arg_empty() const { return NumArgs == 0; }
1471
1472 inline const_name_iterator name_begin() const { return getArgNames().begin();}
1473 inline const_name_iterator name_end () const { return getArgNames().end(); }
1474
1475 inline size_t name_size () const { return NumArgNames; }
1476 inline bool name_empty() const { return NumArgNames == 0; }
1477
1478 Init *getBit(unsigned Bit) const override {
1479 llvm_unreachable("Illegal bit reference off dag");
1480 }
1481};
1482
1483//===----------------------------------------------------------------------===//
1484// High-Level Classes
1485//===----------------------------------------------------------------------===//
1486
1487/// This class represents a field in a record, including its name, type,
1488/// value, and source location.
1490 friend class Record;
1491
1492public:
1494 FK_Normal, // A normal record field.
1495 FK_NonconcreteOK, // A field that can be nonconcrete ('field' keyword).
1496 FK_TemplateArg, // A template argument.
1497 };
1498
1499private:
1500 Init *Name;
1501 SMLoc Loc; // Source location of definition of name.
1503 Init *Value;
1504 bool IsUsed = false;
1505
1506 /// Reference locations to this record value.
1507 SmallVector<SMRange> ReferenceLocs;
1508
1509public:
1511 RecordVal(Init *N, SMLoc Loc, RecTy *T, FieldKind K);
1512
1513 /// Get the record keeper used to unique this value.
1514 RecordKeeper &getRecordKeeper() const { return Name->getRecordKeeper(); }
1515
1516 /// Get the name of the field as a StringRef.
1517 StringRef getName() const;
1518
1519 /// Get the name of the field as an Init.
1520 Init *getNameInit() const { return Name; }
1521
1522 /// Get the name of the field as a std::string.
1523 std::string getNameInitAsString() const {
1524 return getNameInit()->getAsUnquotedString();
1525 }
1526
1527 /// Get the source location of the point where the field was defined.
1528 const SMLoc &getLoc() const { return Loc; }
1529
1530 /// Is this a field where nonconcrete values are okay?
1531 bool isNonconcreteOK() const {
1532 return TyAndKind.getInt() == FK_NonconcreteOK;
1533 }
1534
1535 /// Is this a template argument?
1536 bool isTemplateArg() const {
1537 return TyAndKind.getInt() == FK_TemplateArg;
1538 }
1539
1540 /// Get the type of the field value as a RecTy.
1541 RecTy *getType() const { return TyAndKind.getPointer(); }
1542
1543 /// Get the type of the field for printing purposes.
1544 std::string getPrintType() const;
1545
1546 /// Get the value of the field as an Init.
1547 Init *getValue() const { return Value; }
1548
1549 /// Set the value of the field from an Init.
1550 bool setValue(Init *V);
1551
1552 /// Set the value and source location of the field.
1553 bool setValue(Init *V, SMLoc NewLoc);
1554
1555 /// Add a reference to this record value.
1556 void addReferenceLoc(SMRange Loc) { ReferenceLocs.push_back(Loc); }
1557
1558 /// Return the references of this record value.
1559 ArrayRef<SMRange> getReferenceLocs() const { return ReferenceLocs; }
1560
1561 /// Whether this value is used. Useful for reporting warnings, for example
1562 /// when a template argument is unused.
1563 void setUsed(bool Used) { IsUsed = Used; }
1564 bool isUsed() const { return IsUsed; }
1565
1566 void dump() const;
1567
1568 /// Print the value to an output stream, possibly with a semicolon.
1569 void print(raw_ostream &OS, bool PrintSem = true) const;
1570};
1571
1573 RV.print(OS << " ");
1574 return OS;
1575}
1576
1577class Record {
1578public:
1583
1584 // User-defined constructor to support std::make_unique(). It can be
1585 // removed in C++20 when braced initialization is supported.
1588 };
1589
1590private:
1591 Init *Name;
1592 // Location where record was instantiated, followed by the location of
1593 // multiclass prototypes used, and finally by the locations of references to
1594 // this record.
1596 SmallVector<SMLoc, 0> ForwardDeclarationLocs;
1597 SmallVector<SMRange, 0> ReferenceLocs;
1601
1602 // All superclasses in the inheritance forest in post-order (yes, it
1603 // must be a forest; diamond-shaped inheritance is not allowed).
1605
1606 // Tracks Record instances. Not owned by Record.
1607 RecordKeeper &TrackedRecords;
1608
1609 // The DefInit corresponding to this record.
1610 DefInit *CorrespondingDefInit = nullptr;
1611
1612 // Unique record ID.
1613 unsigned ID;
1614
1615 bool IsAnonymous;
1616 bool IsClass;
1617
1618 void checkName();
1619
1620public:
1621 // Constructs a record.
1622 explicit Record(Init *N, ArrayRef<SMLoc> locs, RecordKeeper &records,
1623 bool Anonymous = false, bool Class = false)
1624 : Name(N), Locs(locs.begin(), locs.end()), TrackedRecords(records),
1625 ID(getNewUID(N->getRecordKeeper())), IsAnonymous(Anonymous),
1626 IsClass(Class) {
1627 checkName();
1628 }
1629
1631 bool Class = false)
1632 : Record(StringInit::get(records, N), locs, records, false, Class) {}
1633
1634 // When copy-constructing a Record, we must still guarantee a globally unique
1635 // ID number. Don't copy CorrespondingDefInit either, since it's owned by the
1636 // original record. All other fields can be copied normally.
1637 Record(const Record &O)
1638 : Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
1639 Values(O.Values), Assertions(O.Assertions),
1640 SuperClasses(O.SuperClasses), TrackedRecords(O.TrackedRecords),
1641 ID(getNewUID(O.getRecords())), IsAnonymous(O.IsAnonymous),
1642 IsClass(O.IsClass) {}
1643
1644 static unsigned getNewUID(RecordKeeper &RK);
1645
1646 unsigned getID() const { return ID; }
1647
1648 StringRef getName() const { return cast<StringInit>(Name)->getValue(); }
1649
1651 return Name;
1652 }
1653
1654 std::string getNameInitAsString() const {
1655 return getNameInit()->getAsUnquotedString();
1656 }
1657
1658 void setName(Init *Name); // Also updates RecordKeeper.
1659
1660 ArrayRef<SMLoc> getLoc() const { return Locs; }
1661 void appendLoc(SMLoc Loc) { Locs.push_back(Loc); }
1662
1664 return ForwardDeclarationLocs;
1665 }
1666
1667 /// Add a reference to this record value.
1668 void appendReferenceLoc(SMRange Loc) { ReferenceLocs.push_back(Loc); }
1669
1670 /// Return the references of this record value.
1671 ArrayRef<SMRange> getReferenceLocs() const { return ReferenceLocs; }
1672
1673 // Update a class location when encountering a (re-)definition.
1674 void updateClassLoc(SMLoc Loc);
1675
1676 // Make the type that this record should have based on its superclasses.
1678
1679 /// get the corresponding DefInit.
1681
1682 bool isClass() const { return IsClass; }
1683
1685 return TemplateArgs;
1686 }
1687
1688 ArrayRef<RecordVal> getValues() const { return Values; }
1689
1690 ArrayRef<AssertionInfo> getAssertions() const { return Assertions; }
1691
1693 return SuperClasses;
1694 }
1695
1696 /// Determine whether this record has the specified direct superclass.
1697 bool hasDirectSuperClass(const Record *SuperClass) const;
1698
1699 /// Append the direct superclasses of this record to Classes.
1701
1702 bool isTemplateArg(Init *Name) const {
1703 return llvm::is_contained(TemplateArgs, Name);
1704 }
1705
1706 const RecordVal *getValue(const Init *Name) const {
1707 for (const RecordVal &Val : Values)
1708 if (Val.Name == Name) return &Val;
1709 return nullptr;
1710 }
1711
1712 const RecordVal *getValue(StringRef Name) const {
1713 return getValue(StringInit::get(getRecords(), Name));
1714 }
1715
1716 RecordVal *getValue(const Init *Name) {
1717 return const_cast<RecordVal *>(static_cast<const Record *>(this)->getValue(Name));
1718 }
1719
1721 return const_cast<RecordVal *>(static_cast<const Record *>(this)->getValue(Name));
1722 }
1723
1724 void addTemplateArg(Init *Name) {
1725 assert(!isTemplateArg(Name) && "Template arg already defined!");
1726 TemplateArgs.push_back(Name);
1727 }
1728
1729 void addValue(const RecordVal &RV) {
1730 assert(getValue(RV.getNameInit()) == nullptr && "Value already added!");
1731 Values.push_back(RV);
1732 }
1733
1734 void removeValue(Init *Name) {
1735 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1736 if (Values[i].getNameInit() == Name) {
1737 Values.erase(Values.begin()+i);
1738 return;
1739 }
1740 llvm_unreachable("Cannot remove an entry that does not exist!");
1741 }
1742
1745 }
1746
1747 void addAssertion(SMLoc Loc, Init *Condition, Init *Message) {
1748 Assertions.push_back(AssertionInfo(Loc, Condition, Message));
1749 }
1750
1751 void appendAssertions(const Record *Rec) {
1752 Assertions.append(Rec->Assertions);
1753 }
1754
1755 void checkRecordAssertions();
1757
1758 bool isSubClassOf(const Record *R) const {
1759 for (const auto &SCPair : SuperClasses)
1760 if (SCPair.first == R)
1761 return true;
1762 return false;
1763 }
1764
1765 bool isSubClassOf(StringRef Name) const {
1766 for (const auto &SCPair : SuperClasses) {
1767 if (const auto *SI = dyn_cast<StringInit>(SCPair.first->getNameInit())) {
1768 if (SI->getValue() == Name)
1769 return true;
1770 } else if (SCPair.first->getNameInitAsString() == Name) {
1771 return true;
1772 }
1773 }
1774 return false;
1775 }
1776
1777 void addSuperClass(Record *R, SMRange Range) {
1778 assert(!CorrespondingDefInit &&
1779 "changing type of record after it has been referenced");
1780 assert(!isSubClassOf(R) && "Already subclassing record!");
1781 SuperClasses.push_back(std::make_pair(R, Range));
1782 }
1783
1784 /// If there are any field references that refer to fields that have been
1785 /// filled in, we can propagate the values now.
1786 ///
1787 /// This is a final resolve: any error messages, e.g. due to undefined !cast
1788 /// references, are generated now.
1789 void resolveReferences(Init *NewName = nullptr);
1790
1791 /// Apply the resolver to the name of the record as well as to the
1792 /// initializers of all fields of the record except SkipVal.
1793 ///
1794 /// The resolver should not resolve any of the fields itself, to avoid
1795 /// recursion / infinite loops.
1796 void resolveReferences(Resolver &R, const RecordVal *SkipVal = nullptr);
1797
1799 return TrackedRecords;
1800 }
1801
1802 bool isAnonymous() const {
1803 return IsAnonymous;
1804 }
1805
1806 void dump() const;
1807
1808 //===--------------------------------------------------------------------===//
1809 // High-level methods useful to tablegen back-ends
1810 //
1811
1812 /// Return the source location for the named field.
1813 SMLoc getFieldLoc(StringRef FieldName) const;
1814
1815 /// Return the initializer for a value with the specified name, or throw an
1816 /// exception if the field does not exist.
1817 Init *getValueInit(StringRef FieldName) const;
1818
1819 /// Return true if the named field is unset.
1820 bool isValueUnset(StringRef FieldName) const {
1821 return isa<UnsetInit>(getValueInit(FieldName));
1822 }
1823
1824 /// This method looks up the specified field and returns its value as a
1825 /// string, throwing an exception if the field does not exist or if the value
1826 /// is not a string.
1827 StringRef getValueAsString(StringRef FieldName) const;
1828
1829 /// This method looks up the specified field and returns its value as a
1830 /// string, throwing an exception if the value is not a string and
1831 /// llvm::Optional() if the field does not exist.
1832 std::optional<StringRef> getValueAsOptionalString(StringRef FieldName) const;
1833
1834 /// This method looks up the specified field and returns its value as a
1835 /// BitsInit, throwing an exception if the field does not exist or if the
1836 /// value is not the right type.
1837 BitsInit *getValueAsBitsInit(StringRef FieldName) const;
1838
1839 /// This method looks up the specified field and returns its value as a
1840 /// ListInit, throwing an exception if the field does not exist or if the
1841 /// value is not the right type.
1842 ListInit *getValueAsListInit(StringRef FieldName) const;
1843
1844 /// This method looks up the specified field and returns its value as a
1845 /// vector of records, throwing an exception if the field does not exist or
1846 /// if the value is not the right type.
1847 std::vector<Record*> getValueAsListOfDefs(StringRef FieldName) const;
1848
1849 /// This method looks up the specified field and returns its value as a
1850 /// vector of integers, throwing an exception if the field does not exist or
1851 /// if the value is not the right type.
1852 std::vector<int64_t> getValueAsListOfInts(StringRef FieldName) const;
1853
1854 /// This method looks up the specified field and returns its value as a
1855 /// vector of strings, throwing an exception if the field does not exist or
1856 /// if the value is not the right type.
1857 std::vector<StringRef> getValueAsListOfStrings(StringRef FieldName) const;
1858
1859 /// This method looks up the specified field and returns its value as a
1860 /// Record, throwing an exception if the field does not exist or if the value
1861 /// is not the right type.
1862 Record *getValueAsDef(StringRef FieldName) const;
1863
1864 /// This method looks up the specified field and returns its value as a
1865 /// Record, returning null if the field exists but is "uninitialized" (i.e.
1866 /// set to `?`), and throwing an exception if the field does not exist or if
1867 /// its value is not the right type.
1868 Record *getValueAsOptionalDef(StringRef FieldName) const;
1869
1870 /// This method looks up the specified field and returns its value as a bit,
1871 /// throwing an exception if the field does not exist or if the value is not
1872 /// the right type.
1873 bool getValueAsBit(StringRef FieldName) const;
1874
1875 /// This method looks up the specified field and returns its value as a bit.
1876 /// If the field is unset, sets Unset to true and returns false.
1877 bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const;
1878
1879 /// This method looks up the specified field and returns its value as an
1880 /// int64_t, throwing an exception if the field does not exist or if the
1881 /// value is not the right type.
1882 int64_t getValueAsInt(StringRef FieldName) const;
1883
1884 /// This method looks up the specified field and returns its value as an Dag,
1885 /// throwing an exception if the field does not exist or if the value is not
1886 /// the right type.
1887 DagInit *getValueAsDag(StringRef FieldName) const;
1888};
1889
1890raw_ostream &operator<<(raw_ostream &OS, const Record &R);
1891
1893 using RecordMap = std::map<std::string, std::unique_ptr<Record>, std::less<>>;
1894 using GlobalMap = std::map<std::string, Init *, std::less<>>;
1895
1896public:
1897 RecordKeeper();
1899
1900 /// Return the internal implementation of the RecordKeeper.
1902
1903 /// Get the main TableGen input file's name.
1904 const std::string getInputFilename() const { return InputFilename; }
1905
1906 /// Get the map of classes.
1907 const RecordMap &getClasses() const { return Classes; }
1908
1909 /// Get the map of records (defs).
1910 const RecordMap &getDefs() const { return Defs; }
1911
1912 /// Get the map of global variables.
1913 const GlobalMap &getGlobals() const { return ExtraGlobals; }
1914
1915 /// Get the class with the specified name.
1917 auto I = Classes.find(Name);
1918 return I == Classes.end() ? nullptr : I->second.get();
1919 }
1920
1921 /// Get the concrete record with the specified name.
1923 auto I = Defs.find(Name);
1924 return I == Defs.end() ? nullptr : I->second.get();
1925 }
1926
1927 /// Get the \p Init value of the specified global variable.
1929 if (Record *R = getDef(Name))
1930 return R->getDefInit();
1931 auto It = ExtraGlobals.find(Name);
1932 return It == ExtraGlobals.end() ? nullptr : It->second;
1933 }
1934
1935 void saveInputFilename(std::string Filename) {
1936 InputFilename = Filename;
1937 }
1938
1939 void addClass(std::unique_ptr<Record> R) {
1940 bool Ins = Classes.insert(std::make_pair(std::string(R->getName()),
1941 std::move(R))).second;
1942 (void)Ins;
1943 assert(Ins && "Class already exists");
1944 }
1945
1946 void addDef(std::unique_ptr<Record> R) {
1947 bool Ins = Defs.insert(std::make_pair(std::string(R->getName()),
1948 std::move(R))).second;
1949 (void)Ins;
1950 assert(Ins && "Record already exists");
1951 }
1952
1954 bool Ins = ExtraGlobals.insert(std::make_pair(std::string(Name), I)).second;
1955 (void)Ins;
1956 assert(!getDef(Name));
1957 assert(Ins && "Global already exists");
1958 }
1959
1961
1962 /// Start phase timing; called if the --time-phases option is specified.
1964 TimingGroup = new TimerGroup("TableGen", "TableGen Phase Timing");
1965 }
1966
1967 /// Start timing a phase. Automatically stops any previous phase timer.
1969
1970 /// Stop timing a phase.
1971 void stopTimer();
1972
1973 /// Start timing the overall backend. If the backend itself starts a timer,
1974 /// then this timer is cleared.
1976
1977 /// Stop timing the overall backend.
1978 void stopBackendTimer();
1979
1980 /// Stop phase timing and print the report.
1982 if (TimingGroup)
1983 delete TimingGroup;
1984 }
1985
1986 //===--------------------------------------------------------------------===//
1987 // High-level helper methods, useful for tablegen backends.
1988
1989 /// Get all the concrete records that inherit from the one specified
1990 /// class. The class must be defined.
1991 std::vector<Record *> getAllDerivedDefinitions(StringRef ClassName) const;
1992
1993 /// Get all the concrete records that inherit from all the specified
1994 /// classes. The classes must be defined.
1995 std::vector<Record *> getAllDerivedDefinitions(
1996 ArrayRef<StringRef> ClassNames) const;
1997
1998 /// Get all the concrete records that inherit from specified class, if the
1999 /// class is defined. Returns an empty vector if the class is not defined.
2000 std::vector<Record *>
2002
2003 void dump() const;
2004
2005private:
2006 RecordKeeper(RecordKeeper &&) = delete;
2007 RecordKeeper(const RecordKeeper &) = delete;
2008 RecordKeeper &operator=(RecordKeeper &&) = delete;
2009 RecordKeeper &operator=(const RecordKeeper &) = delete;
2010
2011 std::string InputFilename;
2012 RecordMap Classes, Defs;
2013 mutable StringMap<std::vector<Record *>> ClassRecordsMap;
2014 GlobalMap ExtraGlobals;
2015
2016 // These members are for the phase timing feature. We need a timer group,
2017 // the last timer started, and a flag to say whether the last timer
2018 // is the special "backend overall timer."
2019 TimerGroup *TimingGroup = nullptr;
2020 Timer *LastTimer = nullptr;
2021 bool BackendTimer = false;
2022
2023 /// The internal uniquer implementation of the RecordKeeper.
2024 std::unique_ptr<detail::RecordKeeperImpl> Impl;
2025};
2026
2027/// Sorting predicate to sort record pointers by name.
2029 bool operator()(const Record *Rec1, const Record *Rec2) const {
2030 return StringRef(Rec1->getName()).compare_numeric(Rec2->getName()) < 0;
2031 }
2032};
2033
2034/// Sorting predicate to sort record pointers by their
2035/// unique ID. If you just need a deterministic order, use this, since it
2036/// just compares two `unsigned`; the other sorting predicates require
2037/// string manipulation.
2039 bool operator()(const Record *LHS, const Record *RHS) const {
2040 return LHS->getID() < RHS->getID();
2041 }
2042};
2043
2044/// Sorting predicate to sort record pointers by their
2045/// name field.
2047 bool operator()(const Record *Rec1, const Record *Rec2) const {
2048 return Rec1->getValueAsString("Name") < Rec2->getValueAsString("Name");
2049 }
2050};
2051
2055
2057 if (Rec.empty())
2058 return;
2059
2060 size_t Len = 0;
2061 const char *Start = Rec.data();
2062 const char *Curr = Start;
2063 bool IsDigitPart = isDigit(Curr[0]);
2064 for (size_t I = 0, E = Rec.size(); I != E; ++I, ++Len) {
2065 bool IsDigit = isDigit(Curr[I]);
2066 if (IsDigit != IsDigitPart) {
2067 Parts.push_back(std::make_pair(IsDigitPart, StringRef(Start, Len)));
2068 Len = 0;
2069 Start = &Curr[I];
2070 IsDigitPart = isDigit(Curr[I]);
2071 }
2072 }
2073 // Push the last part.
2074 Parts.push_back(std::make_pair(IsDigitPart, StringRef(Start, Len)));
2075 }
2076
2077 size_t size() { return Parts.size(); }
2078
2079 std::pair<bool, StringRef> getPart(size_t i) {
2080 assert (i < Parts.size() && "Invalid idx!");
2081 return Parts[i];
2082 }
2083 };
2084
2085 bool operator()(const Record *Rec1, const Record *Rec2) const {
2086 RecordParts LHSParts(StringRef(Rec1->getName()));
2087 RecordParts RHSParts(StringRef(Rec2->getName()));
2088
2089 size_t LHSNumParts = LHSParts.size();
2090 size_t RHSNumParts = RHSParts.size();
2091 assert (LHSNumParts && RHSNumParts && "Expected at least one part!");
2092
2093 if (LHSNumParts != RHSNumParts)
2094 return LHSNumParts < RHSNumParts;
2095
2096 // We expect the registers to be of the form [_a-zA-Z]+([0-9]*[_a-zA-Z]*)*.
2097 for (size_t I = 0, E = LHSNumParts; I < E; I+=2) {
2098 std::pair<bool, StringRef> LHSPart = LHSParts.getPart(I);
2099 std::pair<bool, StringRef> RHSPart = RHSParts.getPart(I);
2100 // Expect even part to always be alpha.
2101 assert (LHSPart.first == false && RHSPart.first == false &&
2102 "Expected both parts to be alpha.");
2103 if (int Res = LHSPart.second.compare(RHSPart.second))
2104 return Res < 0;
2105 }
2106 for (size_t I = 1, E = LHSNumParts; I < E; I+=2) {
2107 std::pair<bool, StringRef> LHSPart = LHSParts.getPart(I);
2108 std::pair<bool, StringRef> RHSPart = RHSParts.getPart(I);
2109 // Expect odd part to always be numeric.
2110 assert (LHSPart.first == true && RHSPart.first == true &&
2111 "Expected both parts to be numeric.");
2112 if (LHSPart.second.size() != RHSPart.second.size())
2113 return LHSPart.second.size() < RHSPart.second.size();
2114
2115 unsigned LHSVal, RHSVal;
2116
2117 bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
2118 assert(!LHSFailed && "Unable to convert LHS to integer.");
2119 bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
2120 assert(!RHSFailed && "Unable to convert RHS to integer.");
2121
2122 if (LHSVal != RHSVal)
2123 return LHSVal < RHSVal;
2124 }
2125 return LHSNumParts < RHSNumParts;
2126 }
2127};
2128
2129raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK);
2130
2131//===----------------------------------------------------------------------===//
2132// Resolvers
2133//===----------------------------------------------------------------------===//
2134
2135/// Interface for looking up the initializer for a variable name, used by
2136/// Init::resolveReferences.
2138 Record *CurRec;
2139 bool IsFinal = false;
2140
2141public:
2142 explicit Resolver(Record *CurRec) : CurRec(CurRec) {}
2143 virtual ~Resolver() = default;
2144
2145 Record *getCurrentRecord() const { return CurRec; }
2146
2147 /// Return the initializer for the given variable name (should normally be a
2148 /// StringInit), or nullptr if the name could not be resolved.
2149 virtual Init *resolve(Init *VarName) = 0;
2150
2151 // Whether bits in a BitsInit should stay unresolved if resolving them would
2152 // result in a ? (UnsetInit). This behavior is used to represent instruction
2153 // encodings by keeping references to unset variables within a record.
2154 virtual bool keepUnsetBits() const { return false; }
2155
2156 // Whether this is the final resolve step before adding a record to the
2157 // RecordKeeper. Error reporting during resolve and related constant folding
2158 // should only happen when this is true.
2159 bool isFinal() const { return IsFinal; }
2160
2161 void setFinal(bool Final) { IsFinal = Final; }
2162};
2163
2164/// Resolve arbitrary mappings.
2165class MapResolver final : public Resolver {
2166 struct MappedValue {
2167 Init *V;
2168 bool Resolved;
2169
2170 MappedValue() : V(nullptr), Resolved(false) {}
2171 MappedValue(Init *V, bool Resolved) : V(V), Resolved(Resolved) {}
2172 };
2173
2175
2176public:
2177 explicit MapResolver(Record *CurRec = nullptr) : Resolver(CurRec) {}
2178
2179 void set(Init *Key, Init *Value) { Map[Key] = {Value, false}; }
2180
2181 bool isComplete(Init *VarName) const {
2182 auto It = Map.find(VarName);
2183 assert(It != Map.end() && "key must be present in map");
2184 return It->second.V->isComplete();
2185 }
2186
2187 Init *resolve(Init *VarName) override;
2188};
2189
2190/// Resolve all variables from a record except for unset variables.
2191class RecordResolver final : public Resolver {
2194 Init *Name = nullptr;
2195
2196public:
2197 explicit RecordResolver(Record &R) : Resolver(&R) {}
2198
2199 void setName(Init *NewName) { Name = NewName; }
2200
2201 Init *resolve(Init *VarName) override;
2202
2203 bool keepUnsetBits() const override { return true; }
2204};
2205
2206/// Delegate resolving to a sub-resolver, but shadow some variable names.
2207class ShadowResolver final : public Resolver {
2208 Resolver &R;
2209 DenseSet<Init *> Shadowed;
2210
2211public:
2213 : Resolver(R.getCurrentRecord()), R(R) {
2214 setFinal(R.isFinal());
2215 }
2216
2217 void addShadow(Init *Key) { Shadowed.insert(Key); }
2218
2219 Init *resolve(Init *VarName) override {
2220 if (Shadowed.count(VarName))
2221 return nullptr;
2222 return R.resolve(VarName);
2223 }
2224};
2225
2226/// (Optionally) delegate resolving to a sub-resolver, and keep track whether
2227/// there were unresolved references.
2228class TrackUnresolvedResolver final : public Resolver {
2229 Resolver *R;
2230 bool FoundUnresolved = false;
2231
2232public:
2233 explicit TrackUnresolvedResolver(Resolver *R = nullptr)
2234 : Resolver(R ? R->getCurrentRecord() : nullptr), R(R) {}
2235
2236 bool foundUnresolved() const { return FoundUnresolved; }
2237
2238 Init *resolve(Init *VarName) override;
2239};
2240
2241/// Do not resolve anything, but keep track of whether a given variable was
2242/// referenced.
2243class HasReferenceResolver final : public Resolver {
2244 Init *VarNameToTrack;
2245 bool Found = false;
2246
2247public:
2248 explicit HasReferenceResolver(Init *VarNameToTrack)
2249 : Resolver(nullptr), VarNameToTrack(VarNameToTrack) {}
2250
2251 bool found() const { return Found; }
2252
2253 Init *resolve(Init *VarName) override;
2254};
2255
2256void EmitDetailedRecords(RecordKeeper &RK, raw_ostream &OS);
2257void EmitJSON(RecordKeeper &RK, raw_ostream &OS);
2258
2259} // end namespace llvm
2260
2261#endif // LLVM_TABLEGEN_RECORD_H
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
std::string Name
This file defines a hash set that can be used to remove duplication of nodes in a graph.
#define I(x, y, z)
Definition: MD5.cpp:58
mir Rename Register Operands
Load MIR Sample Profile
#define T1
This file defines the PointerIntPair class.
const NodeList & List
Definition: RDFGraph.cpp:199
static bool isDigit(const char C)
@ SI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
This file contains some functions that are useful when dealing with strings.
This header defines support for implementing classes that have some trailing object (or arrays of obj...
Value * RHS
Value * LHS
"anonymous_n" - Represent an anonymous record name
Definition: Record.h:609
unsigned getValue() const
Definition: Record.h:625
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:587
StringInit * getNameInit() const
Definition: Record.cpp:579
static AnonymousNameInit * get(RecordKeeper &RK, unsigned)
Definition: Record.cpp:575
AnonymousNameInit(const AnonymousNameInit &)=delete
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:633
static bool classof(const Init *I)
Definition: Record.h:619
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:583
AnonymousNameInit & operator=(const AnonymousNameInit &)=delete
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
!op (X, Y) - Combine two inits.
Definition: Record.h:835
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:1284
Init * getLHS() const
Definition: Record.h:901
Init * getRHS() const
Definition: Record.h:902
OpInit * clone(ArrayRef< Init * > Operands) const override
Definition: Record.h:885
std::optional< bool > CompareInit(unsigned Opc, Init *LHS, Init *RHS) const
Definition: Record.cpp:1040
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1294
unsigned getNumOperands() const override
Definition: Record.h:891
BinaryOp getOpcode() const
Definition: Record.h:900
BinOpInit & operator=(const BinOpInit &)=delete
Init * getOperand(unsigned i) const override
Definition: Record.h:892
Init * Fold(Record *CurRec) const
Definition: Record.cpp:1116
static Init * getStrConcat(Init *lhs, Init *rhs)
Definition: Record.cpp:1013
static bool classof(const Init *I)
Definition: Record.h:873
static Init * getListConcat(TypedInit *lhs, Init *rhs)
Definition: Record.cpp:1030
static BinOpInit * get(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type)
Definition: Record.cpp:943
BinOpInit(const BinOpInit &)=delete
'true'/'false' - Represent a concrete initializer for a bit.
Definition: Record.h:496
BitInit(const BitInit &)=delete
static BitInit * get(RecordKeeper &RK, bool V)
Definition: Record.cpp:372
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.h:523
BitInit & operator=(BitInit &)=delete
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:376
bool getValue() const
Definition: Record.h:513
static bool classof(const Init *I)
Definition: Record.h:507
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:517
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.h:522
'bit' - Represent a single bit
Definition: Record.h:109
static BitRecTy * get(RecordKeeper &RK)
Definition: Record.cpp:121
static bool classof(const RecTy *RT)
Definition: Record.h:115
std::string getAsString() const override
Definition: Record.h:121
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:125
'{ a, b, c }' - Represents an initializer for a BitsRecTy value.
Definition: Record.h:529
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.h:555
bool allInComplete() const
Definition: Record.h:561
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:482
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:468
static bool classof(const Init *I)
Definition: Record.h:542
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:572
unsigned getNumBits() const
Definition: Record.h:550
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
Definition: Record.cpp:449
BitsInit & operator=(const BitsInit &)=delete
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:422
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:460
BitsInit(const BitsInit &)=delete
static BitsInit * get(RecordKeeper &RK, ArrayRef< Init * > Range)
Definition: Record.cpp:400
'bits<n>' - Represent a fixed number of bits
Definition: Record.h:127
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:147
unsigned getNumBits() const
Definition: Record.h:140
static bool classof(const RecTy *RT)
Definition: Record.h:134
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
Definition: Record.cpp:154
std::string getAsString() const override
Definition: Record.cpp:143
static BitsRecTy * get(RecordKeeper &RK, unsigned Sz)
Definition: Record.cpp:133
!cond(condition_1: value1, ... , condition_n: value) Selects the first value for which condition is t...
Definition: Record.h:981
CondOpInit & operator=(const CondOpInit &)=delete
Init * getCond(unsigned Num) const
Definition: Record.h:1010
const_val_iterator name_end() const
Definition: Record.h:1046
bool case_empty() const
Definition: Record.h:1043
const_case_iterator arg_end() const
Definition: Record.h:1040
ArrayRef< Init * > getVals() const
Definition: Record.h:1024
static CondOpInit * get(ArrayRef< Init * > C, ArrayRef< Init * > V, RecTy *Type)
Definition: Record.cpp:2198
size_t case_size() const
Definition: Record.h:1042
CondOpInit(const CondOpInit &)=delete
ArrayRef< Init * > getConds() const
Definition: Record.h:1020
size_t val_size() const
Definition: Record.h:1048
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:2268
SmallVectorImpl< Init * >::const_iterator const_case_iterator
Definition: Record.h:1036
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:2303
const_val_iterator name_begin() const
Definition: Record.h:1045
SmallVectorImpl< Init * >::const_iterator const_val_iterator
Definition: Record.h:1037
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:2292
Init * Fold(Record *CurRec) const
Definition: Record.cpp:2246
unsigned getNumConds() const
Definition: Record.h:1008
RecTy * getValType() const
Definition: Record.h:1006
Init * getVal(unsigned Num) const
Definition: Record.h:1015
bool val_empty() const
Definition: Record.h:1049
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:2223
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.cpp:2280
static bool classof(const Init *I)
Definition: Record.h:997
const_case_iterator arg_begin() const
Definition: Record.h:1039
(v a, b) - Represent a DAG tree value.
Definition: Record.h:1395
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:2390
unsigned getNumArgs() const
Definition: Record.h:1433
StringInit * getName() const
Definition: Record.h:1427
Init * getOperator() const
Definition: Record.h:1424
size_t name_size() const
Definition: Record.h:1475
DagInit(const DagInit &)=delete
StringInit * getArgName(unsigned Num) const
Definition: Record.h:1440
StringRef getArgNameStr(unsigned Num) const
Definition: Record.h:1445
Record * getOperatorAsDef(ArrayRef< SMLoc > Loc) const
Definition: Record.cpp:2366
const_arg_iterator arg_begin() const
Definition: Record.h:1466
const_arg_iterator arg_end() const
Definition: Record.h:1467
ArrayRef< StringInit * > getArgNames() const
Definition: Record.h:1454
static DagInit * get(Init *V, StringInit *VN, ArrayRef< Init * > ArgRange, ArrayRef< StringInit * > NameRange)
Definition: Record.cpp:2323
Init * getArg(unsigned Num) const
Definition: Record.h:1435
static bool classof(const Init *I)
Definition: Record.h:1413
bool name_empty() const
Definition: Record.h:1476
SmallVectorImpl< StringInit * >::const_iterator const_name_iterator
Definition: Record.h:1464
const_name_iterator name_end() const
Definition: Record.h:1473
ArrayRef< Init * > getArgs() const
Definition: Record.h:1450
const_name_iterator name_begin() const
Definition: Record.h:1472
size_t arg_size() const
Definition: Record.h:1469
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:1478
bool arg_empty() const
Definition: Record.h:1470
StringRef getNameStr() const
Definition: Record.h:1429
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:2373
DagInit & operator=(const DagInit &)=delete
SmallVectorImpl< Init * >::const_iterator const_arg_iterator
Definition: Record.h:1463
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:2400
'dag' - Represent a dag fragment
Definition: Record.h:211
std::string getAsString() const override
Definition: Record.cpp:202
static DagRecTy * get(RecordKeeper &RK)
Definition: Record.cpp:198
static bool classof(const RecTy *RT)
Definition: Record.h:217
AL - Represent a reference to a 'def' in the description.
Definition: Record.h:1266
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:1984
DefInit & operator=(const DefInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1997
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:1294
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
Definition: Record.cpp:1991
DefInit(const DefInit &)=delete
static bool classof(const Init *I)
Definition: Record.h:1277
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.h:1291
static DefInit * get(Record *)
Definition: Record.cpp:1980
Record * getDef() const
Definition: Record.h:1285
Implements a dense probed hash-table based set.
Definition: DenseSet.h:271
!exists<type>(expr) - Dynamically determine if a record of type named expr exists.
Definition: Record.h:1126
static bool classof(const Init *I)
Definition: Record.h:1139
Init * Fold(Record *CurRec, bool IsFinal=false) const
Definition: Record.cpp:1773
ExistsOpInit(const ExistsOpInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.h:1149
static ExistsOpInit * get(RecTy *CheckType, Init *Expr)
Definition: Record.cpp:1755
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1818
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:1807
ExistsOpInit & operator=(const ExistsOpInit &)=delete
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1814
X.Y - Represent a reference to a subfield of a variable.
Definition: Record.h:1351
static bool classof(const Init *I)
Definition: Record.h:1371
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.h:1386
Init * getRecord() const
Definition: Record.h:1377
StringInit * getFieldName() const
Definition: Record.h:1378
Init * Fold(Record *CurRec) const
Definition: Record.cpp:2153
static FieldInit * get(Init *R, StringInit *FN)
Definition: Record.cpp:2132
FieldInit & operator=(const FieldInit &)=delete
FieldInit(const FieldInit &)=delete
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:2140
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:2146
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:2168
!foldl (a, b, expr, start, lst) - Fold over a list.
Definition: Record.h:1055
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:1661
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1676
static bool classof(const Init *I)
Definition: Record.h:1071
FoldOpInit & operator=(const FoldOpInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1680
FoldOpInit(const FoldOpInit &)=delete
Init * Fold(Record *CurRec) const
Definition: Record.cpp:1647
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.h:1082
static FoldOpInit * get(Init *Start, Init *List, Init *A, Init *B, Init *Expr, RecTy *Type)
Definition: Record.cpp:1628
Node - This class is used to maintain the singly linked bucket list in a folding set.
Definition: FoldingSet.h:136
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:318
Do not resolve anything, but keep track of whether a given variable was referenced.
Definition: Record.h:2243
HasReferenceResolver(Init *VarNameToTrack)
Definition: Record.h:2248
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.cpp:3064
uint8_t Opc
Definition: Record.h:330
virtual Init * getBit(unsigned Bit) const =0
Get the Init value of the specified bit.
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:408
virtual std::string getAsUnquotedString() const
Convert this value to a literal form, without adding quotes around a string.
Definition: Record.h:365
void dump() const
Debugging method that may be called through a debugger; just invokes print on stderr.
Definition: Record.cpp:351
void print(raw_ostream &OS) const
Print this value.
Definition: Record.h:358
virtual std::string getAsString() const =0
Convert this value to a literal form.
InitKind
Discriminator enum (for isa<>, dyn_cast<>, et al.)
Definition: Record.h:297
@ IK_FoldOpInit
Definition: Record.h:313
@ IK_IntInit
Definition: Record.h:305
@ IK_LastTypedInit
Definition: Record.h:322
@ IK_UnsetInit
Definition: Record.h:323
@ IK_DagInit
Definition: Record.h:302
@ IK_VarBitInit
Definition: Record.h:320
@ IK_ListInit
Definition: Record.h:306
@ IK_FirstOpInit
Definition: Record.h:307
@ IK_VarDefInit
Definition: Record.h:321
@ IK_VarListElementInit
Definition: Record.h:319
@ IK_ExistsOpInit
Definition: Record.h:315
@ IK_DefInit
Definition: Record.h:303
@ IK_BinOpInit
Definition: Record.h:308
@ IK_FirstTypedInit
Definition: Record.h:299
@ IK_BitInit
Definition: Record.h:300
@ IK_BitsInit
Definition: Record.h:301
@ IK_UnOpInit
Definition: Record.h:310
@ IK_StringInit
Definition: Record.h:317
@ IK_IsAOpInit
Definition: Record.h:314
@ IK_First
Definition: Record.h:298
@ IK_VarInit
Definition: Record.h:318
@ IK_LastOpInit
Definition: Record.h:311
@ IK_AnonymousNameInit
Definition: Record.h:316
@ IK_CondOpInit
Definition: Record.h:312
@ IK_FieldInit
Definition: Record.h:304
@ IK_TernOpInit
Definition: Record.h:309
InitKind getKind() const
Get the kind (type) of the value.
Definition: Record.h:337
virtual Init * convertInitListSlice(ArrayRef< unsigned > Elements) const
This function is used to implement the list slice selection operator.
Definition: Record.h:393
virtual Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const
This function is used to implement the bit range selection operator.
Definition: Record.h:385
virtual bool isConcrete() const
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.h:355
virtual bool isComplete() const
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.h:351
virtual ~Init()=default
Init(const Init &)=delete
virtual Init * getCastTo(RecTy *Ty) const =0
If this value is convertible to type Ty, return a value whose type is Ty, generating a !...
Init & operator=(const Init &)=delete
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
Definition: Record.cpp:354
virtual RecTy * getFieldType(StringInit *FieldName) const
This function is used to implement the FieldInit class.
Definition: Record.h:400
virtual Init * convertInitializerTo(RecTy *Ty) const =0
Convert to a value whose type is Ty, or return null if this is not possible.
Init(InitKind K, uint8_t Opc=0)
Definition: Record.h:343
'7' - Represent an initialization by a literal integer value.
Definition: Record.h:579
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
Definition: Record.cpp:562
IntInit(const IntInit &)=delete
static IntInit * get(RecordKeeper &RK, int64_t V)
Definition: Record.cpp:517
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:603
static bool classof(const Init *I)
Definition: Record.h:589
IntInit & operator=(const IntInit &)=delete
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:534
int64_t getValue() const
Definition: Record.h:595
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.h:600
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:524
'int' - Represent an integer value of no particular size
Definition: Record.h:150
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:164
static IntRecTy * get(RecordKeeper &RK)
Definition: Record.cpp:160
std::string getAsString() const override
Definition: Record.h:162
static bool classof(const RecTy *RT)
Definition: Record.h:156
!isa<type>(expr) - Dynamically determine the type of an expression.
Definition: Record.h:1092
IsAOpInit(const IsAOpInit &)=delete
IsAOpInit & operator=(const IsAOpInit &)=delete
static bool classof(const Init *I)
Definition: Record.h:1105
static IsAOpInit * get(RecTy *CheckType, Init *Expr)
Definition: Record.cpp:1693
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.h:1115
Init * Fold() const
Definition: Record.cpp:1712
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1743
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:1732
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1739
[AL, AH, CL] - Represent a list of defs
Definition: Record.h:695
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:736
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This function is used to implement the list slice selection operator.
Definition: Record.cpp:679
ListInit & operator=(const ListInit &)=delete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.cpp:728
static ListInit * get(ArrayRef< Init * > Range, RecTy *EltTy)
Definition: Record.cpp:624
RecTy * getElementType() const
Definition: Record.h:723
ListInit(const ListInit &)=delete
Init * getElement(unsigned i) const
Definition: Record.h:719
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.cpp:720
size_t size() const
Definition: Record.h:751
Init *const * const_iterator
Definition: Record.h:699
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:651
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:754
ArrayRef< Init * > getValues() const
Definition: Record.h:744
Record * getElementAsRecord(unsigned i) const
Definition: Record.cpp:696
const_iterator begin() const
Definition: Record.h:748
const_iterator end() const
Definition: Record.h:749
bool empty() const
Definition: Record.h:752
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:704
static bool classof(const Init *I)
Definition: Record.h:712
'list<Ty>' - Represent a list of element values, all of which must be of the specified type.
Definition: Record.h:187
static bool classof(const RecTy *RT)
Definition: Record.h:196
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
Definition: Record.cpp:192
std::string getAsString() const override
Definition: Record.cpp:182
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:186
RecTy * getElementType() const
Definition: Record.h:201
static ListRecTy * get(RecTy *T)
Definition: Record.h:200
Resolve arbitrary mappings.
Definition: Record.h:2165
void set(Init *Key, Init *Value)
Definition: Record.h:2179
MapResolver(Record *CurRec=nullptr)
Definition: Record.h:2177
bool isComplete(Init *VarName) const
Definition: Record.h:2181
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.cpp:3001
Base class for operators.
Definition: Record.h:761
virtual Init * getOperand(unsigned i) const =0
virtual unsigned getNumOperands() const =0
OpInit & operator=(OpInit &)=delete
static bool classof(const Init *I)
Definition: Record.h:770
OpInit(const OpInit &)=delete
virtual OpInit * clone(ArrayRef< Init * > Operands) const =0
OpInit(InitKind K, RecTy *Type, uint8_t Opc)
Definition: Record.h:763
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:747
PointerIntPair - This class implements a pair of a pointer and small integer.
IntType getInt() const
PointerTy getPointer() const
RecordKeeper & getRecordKeeper() const
Return the RecordKeeper that uniqued this Type.
Definition: Record.h:85
ListRecTy * getListTy()
Returns the type representing list<thistype>.
Definition: Record.cpp:108
virtual bool typeIsA(const RecTy *RHS) const
Return true if 'this' type is equal to or a subtype of RHS.
Definition: Record.cpp:119
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:114
RecTyKind
Subclass discriminator (for dyn_cast<> et al.)
Definition: Record.h:61
@ RecordRecTyKind
Definition: Record.h:68
@ ListRecTyKind
Definition: Record.h:66
@ BitsRecTyKind
Definition: Record.h:63
@ DagRecTyKind
Definition: Record.h:67
@ IntRecTyKind
Definition: Record.h:64
@ StringRecTyKind
Definition: Record.h:65
@ BitRecTyKind
Definition: Record.h:62
RecTy(RecTyKind K, RecordKeeper &RK)
Definition: Record.h:79
virtual std::string getAsString() const =0
RecTyKind getRecTyKind() const
Definition: Record.h:82
void dump() const
Definition: Record.cpp:105
virtual ~RecTy()=default
void print(raw_ostream &OS) const
Definition: Record.h:88
void addDef(std::unique_ptr< Record > R)
Definition: Record.h:1946
void addClass(std::unique_ptr< Record > R)
Definition: Record.h:1939
std::vector< Record * > getAllDerivedDefinitions(StringRef ClassName) const
Get all the concrete records that inherit from the one specified class.
Definition: Record.cpp:2962
Record * getDef(StringRef Name) const
Get the concrete record with the specified name.
Definition: Record.h:1922
const RecordMap & getClasses() const
Get the map of classes.
Definition: Record.h:1907
Record * getClass(StringRef Name) const
Get the class with the specified name.
Definition: Record.h:1916
void stopPhaseTiming()
Stop phase timing and print the report.
Definition: Record.h:1981
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:2996
const RecordMap & getDefs() const
Get the map of records (defs).
Definition: Record.h:1910
void dump() const
Definition: Record.cpp:2900
detail::RecordKeeperImpl & getImpl()
Return the internal implementation of the RecordKeeper.
Definition: Record.h:1901
void stopBackendTimer()
Stop timing the overall backend.
Definition: Record.cpp:2952
void saveInputFilename(std::string Filename)
Definition: Record.h:1935
void startPhaseTiming()
Start phase timing; called if the –time-phases option is specified.
Definition: Record.h:1963
const GlobalMap & getGlobals() const
Get the map of global variables.
Definition: Record.h:1913
void stopTimer()
Stop timing a phase.
Definition: Record.cpp:2938
void startTimer(StringRef Name)
Start timing a phase. Automatically stops any previous phase timer.
Definition: Record.cpp:2923
void addExtraGlobal(StringRef Name, Init *I)
Definition: Record.h:1953
Init * getNewAnonymousName()
GetNewAnonymousName - Generate a unique anonymous name that can be used as an identifier.
Definition: Record.cpp:2916
Init * getGlobal(StringRef Name) const
Get the Init value of the specified global variable.
Definition: Record.h:1928
const std::string getInputFilename() const
Get the main TableGen input file's name.
Definition: Record.h:1904
void startBackendTimer(StringRef Name)
Start timing the overall backend.
Definition: Record.cpp:2945
'[classname]' - Type of record values that have zero or more superclasses.
Definition: Record.h:231
Record *const * const_record_iterator
Definition: Record.h:261
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:284
RecordRecTy & operator=(const RecordRecTy &)=delete
static RecordRecTy * get(RecordKeeper &RK, ArrayRef< Record * > Classes)
Get the record type with the given non-redundant list of superclasses.
Definition: Record.cpp:213
const_record_iterator classes_begin() const
Definition: Record.h:263
const_record_iterator classes_end() const
Definition: Record.h:264
std::string getAsString() const override
Definition: Record.cpp:261
RecordRecTy(const RecordRecTy &)=delete
bool typeIsA(const RecTy *RHS) const override
Return true if 'this' type is equal to or a subtype of RHS.
Definition: Record.cpp:297
static bool classof(const RecTy *RT)
Definition: Record.h:247
bool isSubClassOf(Record *Class) const
Definition: Record.cpp:277
ArrayRef< Record * > getClasses() const
Definition: Record.h:257
Resolve all variables from a record except for unset variables.
Definition: Record.h:2191
void setName(Init *NewName)
Definition: Record.h:2199
bool keepUnsetBits() const override
Definition: Record.h:2203
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.cpp:3019
RecordResolver(Record &R)
Definition: Record.h:2197
This class represents a field in a record, including its name, type, value, and source location.
Definition: Record.h:1489
bool setValue(Init *V)
Set the value of the field from an Init.
Definition: Record.cpp:2452
bool isTemplateArg() const
Is this a template argument?
Definition: Record.h:1536
std::string getNameInitAsString() const
Get the name of the field as a std::string.
Definition: Record.h:1523
void setUsed(bool Used)
Whether this value is used.
Definition: Record.h:1563
bool isNonconcreteOK() const
Is this a field where nonconcrete values are okay?
Definition: Record.h:1531
RecordKeeper & getRecordKeeper() const
Get the record keeper used to unique this value.
Definition: Record.h:1514
const SMLoc & getLoc() const
Get the source location of the point where the field was defined.
Definition: Record.h:1528
bool isUsed() const
Definition: Record.h:1564
void dump() const
Definition: Record.cpp:2501
StringRef getName() const
Get the name of the field as a StringRef.
Definition: Record.cpp:2433
void addReferenceLoc(SMRange Loc)
Add a reference to this record value.
Definition: Record.h:1556
void print(raw_ostream &OS, bool PrintSem=true) const
Print the value to an output stream, possibly with a semicolon.
Definition: Record.cpp:2504
RecTy * getType() const
Get the type of the field value as a RecTy.
Definition: Record.h:1541
Init * getNameInit() const
Get the name of the field as an Init.
Definition: Record.h:1520
ArrayRef< SMRange > getReferenceLocs() const
Return the references of this record value.
Definition: Record.h:1559
std::string getPrintType() const
Get the type of the field for printing purposes.
Definition: Record.cpp:2437
Init * getValue() const
Get the value of the field as an Init.
Definition: Record.h:1547
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:2771
void addAssertion(SMLoc Loc, Init *Condition, Init *Message)
Definition: Record.h:1747
bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const
This method looks up the specified field and returns its value as a bit.
Definition: Record.cpp:2841
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:2829
unsigned getID() const
Definition: Record.h:1646
static unsigned getNewUID(RecordKeeper &RK)
Definition: Record.cpp:2544
ArrayRef< SMLoc > getLoc() const
Definition: Record.h:1660
void appendReferenceLoc(SMRange Loc)
Add a reference to this record value.
Definition: Record.h:1668
void checkUnusedTemplateArgs()
Definition: Record.cpp:2886
bool isAnonymous() const
Definition: Record.h:1802
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:2814
ArrayRef< AssertionInfo > getAssertions() const
Definition: Record.h:1690
std::string getNameInitAsString() const
Definition: Record.h:1654
Init * getNameInit() const
Definition: Record.h:1650
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:2730
void removeValue(StringRef Name)
Definition: Record.h:1743
void dump() const
Definition: Record.cpp:2639
void getDirectSuperClasses(SmallVectorImpl< Record * > &Classes) const
Append the direct superclasses of this record to Classes.
Definition: Record.cpp:2582
RecordKeeper & getRecords() const
Definition: Record.h:1798
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:2718
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:2787
const RecordVal * getValue(const Init *Name) const
Definition: Record.h:1706
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:2802
void appendLoc(SMLoc Loc)
Definition: Record.h:1661
Record(const Record &O)
Definition: Record.h:1637
bool isValueUnset(StringRef FieldName) const
Return true if the named field is unset.
Definition: Record.h:1820
void addValue(const RecordVal &RV)
Definition: Record.h:1729
Record(Init *N, ArrayRef< SMLoc > locs, RecordKeeper &records, bool Anonymous=false, bool Class=false)
Definition: Record.h:1622
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:2858
bool hasDirectSuperClass(const Record *SuperClass) const
Determine whether this record has the specified direct superclass.
Definition: Record.cpp:2569
bool isClass() const
Definition: Record.h:1682
StringRef getName() const
Definition: Record.h:1648
bool isSubClassOf(StringRef Name) const
Definition: Record.h:1765
void addTemplateArg(Init *Name)
Definition: Record.h:1724
ArrayRef< Init * > getTemplateArgs() const
Definition: Record.h:1684
bool isSubClassOf(const Record *R) const
Definition: Record.h:1758
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:2686
ArrayRef< RecordVal > getValues() const
Definition: Record.h:1688
SMLoc getFieldLoc(StringRef FieldName) const
Return the source location for the named field.
Definition: Record.cpp:2678
ArrayRef< SMLoc > getForwardDeclarationLocs() const
Definition: Record.h:1663
const RecordVal * getValue(StringRef Name) const
Definition: Record.h:1712
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:2743
void addSuperClass(Record *R, SMRange Range)
Definition: Record.h:1777
bool isTemplateArg(Init *Name) const
Definition: Record.h:1702
std::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:2703
DefInit * getDefInit()
get the corresponding DefInit.
Definition: Record.cpp:2536
ArrayRef< SMRange > getReferenceLocs() const
Return the references of this record value.
Definition: Record.h:1671
void updateClassLoc(SMLoc Loc)
Definition: Record.cpp:2514
RecordVal * getValue(const Init *Name)
Definition: Record.h:1716
RecordRecTy * getType()
Definition: Record.cpp:2530
Record(StringRef N, ArrayRef< SMLoc > locs, RecordKeeper &records, bool Class=false)
Definition: Record.h:1630
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:2631
void setName(Init *Name)
Definition: Record.cpp:2548
void appendAssertions(const Record *Rec)
Definition: Record.h:1751
ArrayRef< std::pair< Record *, SMRange > > getSuperClasses() const
Definition: Record.h:1692
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:2756
void removeValue(Init *Name)
Definition: Record.h:1734
RecordVal * getValue(StringRef Name)
Definition: Record.h:1720
void checkRecordAssertions()
Definition: Record.cpp:2874
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:2694
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2137
virtual ~Resolver()=default
bool isFinal() const
Definition: Record.h:2159
Record * getCurrentRecord() const
Definition: Record.h:2145
void setFinal(bool Final)
Definition: Record.h:2161
virtual Init * resolve(Init *VarName)=0
Return the initializer for the given variable name (should normally be a StringInit),...
virtual bool keepUnsetBits() const
Definition: Record.h:2154
Resolver(Record *CurRec)
Definition: Record.h:2142
Represents a location in source code.
Definition: SMLoc.h:23
Represents a range in source code.
Definition: SMLoc.h:48
Delegate resolving to a sub-resolver, but shadow some variable names.
Definition: Record.h:2207
ShadowResolver(Resolver &R)
Definition: Record.h:2212
void addShadow(Init *Key)
Definition: Record.h:2217
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.h:2219
size_t size() const
Definition: SmallVector.h:91
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:577
iterator erase(const_iterator CI)
Definition: SmallVector.h:741
typename SuperClass::const_iterator const_iterator
Definition: SmallVector.h:582
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:687
void push_back(const T &Elt)
Definition: SmallVector.h:416
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
"foo" - Represent an initialization by a string value.
Definition: Record.h:639
StringInit(const StringInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.h:676
StringInit & operator=(const StringInit &)=delete
StringFormat getFormat() const
Definition: Record.h:669
bool hasCodeFormat() const
Definition: Record.h:670
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:607
StringRef getValue() const
Definition: Record.h:668
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.h:674
static StringFormat determineFormat(StringFormat Fmt1, StringFormat Fmt2)
Definition: Record.h:664
static StringInit * get(RecordKeeper &RK, StringRef, StringFormat Fmt=SF_String)
Definition: Record.cpp:597
static bool classof(const Init *I)
Definition: Record.h:657
std::string getAsUnquotedString() const override
Convert this value to a literal form, without adding quotes around a string.
Definition: Record.h:683
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:687
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:111
'string' - Represent an string value
Definition: Record.h:168
static bool classof(const RecTy *RT)
Definition: Record.h:174
static StringRecTy * get(RecordKeeper &RK)
Definition: Record.cpp:169
std::string getAsString() const override
Definition: Record.cpp:173
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:177
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:222
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
int compare_numeric(StringRef RHS) const
compare_numeric - Compare two strings, treating sequences of digits as numbers.
Definition: StringRef.cpp:61
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:131
!op (X, Y, Z) - Combine two inits.
Definition: Record.h:916
OpInit * clone(ArrayRef< Init * > Operands) const override
Definition: Record.h:942
TernOpInit(const TernOpInit &)=delete
Init * getRHS() const
Definition: Record.h:962
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.h:968
Init * Fold(Record *CurRec) const
Definition: Record.cpp:1433
unsigned getNumOperands() const override
Definition: Record.h:949
static bool classof(const Init *I)
Definition: Record.h:931
Init * getLHS() const
Definition: Record.h:960
Init * getOperand(unsigned i) const override
Definition: Record.h:950
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1601
TernOpInit & operator=(const TernOpInit &)=delete
TernaryOp getOpcode() const
Definition: Record.h:959
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:1571
Init * getMHS() const
Definition: Record.h:961
static TernOpInit * get(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type)
Definition: Record.cpp:1334
The TimerGroup class is used to group together related timers into a single report that is printed wh...
Definition: Timer.h:175
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
Definition: Timer.h:81
(Optionally) delegate resolving to a sub-resolver, and keep track whether there were unresolved refer...
Definition: Record.h:2228
bool foundUnresolved() const
Definition: Record.h:2236
TrackUnresolvedResolver(Resolver *R=nullptr)
Definition: Record.h:2233
Init * resolve(Init *VarName) override
Return the initializer for the given variable name (should normally be a StringInit),...
Definition: Record.cpp:3044
See the file comment for details on the usage of the TrailingObjects type.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
This is the common superclass of types that have a specific, explicit type, stored in ValueTy.
Definition: Record.h:422
static bool classof(const Init *I)
Definition: Record.h:433
TypedInit(InitKind K, RecTy *T, uint8_t Opc=0)
Definition: Record.h:426
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:1862
RecTy * getFieldType(StringInit *FieldName) const override
This method is used to implement the FieldInit class.
Definition: Record.cpp:1824
Init * convertInitListSlice(ArrayRef< unsigned > Elements) const override
This function is used to implement the list slice selection operator.
Definition: Record.cpp:1880
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
Definition: Record.h:442
TypedInit(const TypedInit &)=delete
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:1835
TypedInit & operator=(const TypedInit &)=delete
RecTy * getType() const
Get the type of the Init as a RecTy.
Definition: Record.h:439
Init * convertInitializerBitRange(ArrayRef< unsigned > Bits) const override
This function is used to implement the bit range selection operator.
Definition: Record.cpp:1846
!op (X) - Transform an init.
Definition: Record.h:786
Init * getOperand() const
Definition: Record.h:823
UnOpInit & operator=(const UnOpInit &)=delete
Init * Fold(Record *CurRec, bool IsFinal=false) const
Definition: Record.cpp:778
static bool classof(const Init *I)
Definition: Record.h:800
UnaryOp getOpcode() const
Definition: Record.h:822
OpInit * clone(ArrayRef< Init * > Operands) const override
Definition: Record.h:809
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:910
unsigned getNumOperands() const override
Definition: Record.h:815
UnOpInit(const UnOpInit &)=delete
static UnOpInit * get(UnaryOp opc, Init *lhs, RecTy *Type)
Definition: Record.cpp:760
Init * getOperand(unsigned i) const override
Definition: Record.h:817
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:919
'?' - Represents an uninitialized value.
Definition: Record.h:457
UnsetInit & operator=(const UnsetInit &)=delete
bool isComplete() const override
Is this a complete value with no unset (uninitialized) subvalues?
Definition: Record.h:487
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:364
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:482
UnsetInit(const UnsetInit &)=delete
bool isConcrete() const override
Is this a concrete and fully resolved value without any references or stuck operations?...
Definition: Record.h:489
static UnsetInit * get(RecordKeeper &RK)
Get the singleton unset Init.
Definition: Record.cpp:360
static bool classof(const Init *I)
Definition: Record.h:469
std::string getAsString() const override
Get the string representation of the Init.
Definition: Record.h:492
RecordKeeper & getRecordKeeper() const
Get the record keeper that initialized this Init.
Definition: Record.h:477
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:368
LLVM Value Representation.
Definition: Value.h:74
Opcode{0} - Represent access to one bit of a variable or field.
Definition: Record.h:1196
unsigned getBitNum() const
Definition: Record.h:1221
VarBitInit(const VarBitInit &)=delete
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1934
Init * getBit(unsigned B) const override
Get the Init value of the specified bit.
Definition: Record.h:1226
Init * getBitVar() const
Definition: Record.h:1220
static bool classof(const Init *I)
Definition: Record.h:1214
static VarBitInit * get(TypedInit *T, unsigned B)
Definition: Record.cpp:1926
VarBitInit & operator=(const VarBitInit &)=delete
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:1938
classname<targs...> - Represent an uninstantiated anonymous class instantiation.
Definition: Record.h:1302
size_t args_size() const
Definition: Record.h:1340
Init * Fold() const
Definition: Record.cpp:2108
const_iterator args_end() const
Definition: Record.h:1338
static VarDefInit * get(Record *Class, ArrayRef< Init * > Args)
Definition: Record.cpp:2013
const_iterator args_begin() const
Definition: Record.h:1337
Init *const * const_iterator
Definition: Record.h:1335
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.h:1345
VarDefInit & operator=(const VarDefInit &)=delete
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:2087
static bool classof(const Init *I)
Definition: Record.h:1318
VarDefInit(const VarDefInit &)=delete
ArrayRef< Init * > args() const
Definition: Record.h:1343
bool args_empty() const
Definition: Record.h:1341
Init * getArg(unsigned i) const
Definition: Record.h:1330
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:2121
'Opcode' - Represent a reference to an entire variable object.
Definition: Record.h:1159
VarInit & operator=(const VarInit &)=delete
static bool classof(const Init *I)
Definition: Record.h:1169
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:1920
Init * getNameInit() const
Definition: Record.h:1177
StringRef getName() const
Definition: Record.cpp:1909
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.h:1192
VarInit(const VarInit &)=delete
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1914
static VarInit * get(StringRef VN, RecTy *T)
Definition: Record.cpp:1896
std::string getNameInitAsString() const
Definition: Record.h:1179
List[4] - Represent access to one element of a var or field.
Definition: Record.h:1234
VarListElementInit(const VarListElementInit &)=delete
static VarListElementInit * get(TypedInit *T, unsigned E)
Definition: Record.cpp:1946
static bool classof(const Init *I)
Definition: Record.h:1250
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:1958
Init * getBit(unsigned Bit) const override
Get the Init value of the specified bit.
Definition: Record.cpp:1971
std::string getAsString() const override
Convert this value to a literal form.
Definition: Record.cpp:1954
VarListElementInit & operator=(const VarListElementInit &)=delete
TypedInit * getVariable() const
Definition: Record.h:1256
unsigned getElementNum() const
Definition: Record.h:1257
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Definition: DenseSet.h:97
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
RecTy * resolveTypes(RecTy *T1, RecTy *T2)
Find a common type that T1 and T2 convert to.
Definition: Record.cpp:318
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void EmitJSON(RecordKeeper &RK, raw_ostream &OS)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:292
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:1869
void EmitDetailedRecords(RecordKeeper &RK, raw_ostream &OS)
#define N
#define NC
Definition: regutils.h:42
Sorting predicate to sort record pointers by their unique ID.
Definition: Record.h:2038
bool operator()(const Record *LHS, const Record *RHS) const
Definition: Record.h:2039
Sorting predicate to sort record pointers by their name field.
Definition: Record.h:2046
bool operator()(const Record *Rec1, const Record *Rec2) const
Definition: Record.h:2047
SmallVector< std::pair< bool, StringRef >, 4 > Parts
Definition: Record.h:2054
std::pair< bool, StringRef > getPart(size_t i)
Definition: Record.h:2079
bool operator()(const Record *Rec1, const Record *Rec2) const
Definition: Record.h:2085
Sorting predicate to sort record pointers by name.
Definition: Record.h:2028
bool operator()(const Record *Rec1, const Record *Rec2) const
Definition: Record.h:2029
AssertionInfo(SMLoc Loc, Init *Condition, Init *Message)
Definition: Record.h:1586
This class represents the internal implementation of the RecordKeeper.
Definition: Record.cpp:53