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