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