LCOV - code coverage report
Current view: top level - include/llvm/TableGen - Record.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 226 284 79.6 %
Date: 2018-02-22 16:16:46 Functions: 62 123 50.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- llvm/TableGen/Record.h - Classes for Table Records -------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file defines the main TableGen data structures, including the TableGen
      11             : // types, values, and high-level data structures.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #ifndef LLVM_TABLEGEN_RECORD_H
      16             : #define LLVM_TABLEGEN_RECORD_H
      17             : 
      18             : #include "llvm/ADT/ArrayRef.h"
      19             : #include "llvm/ADT/FoldingSet.h"
      20             : #include "llvm/ADT/PointerIntPair.h"
      21             : #include "llvm/ADT/SmallVector.h"
      22             : #include "llvm/ADT/StringRef.h"
      23             : #include "llvm/Support/Casting.h"
      24             : #include "llvm/Support/ErrorHandling.h"
      25             : #include "llvm/Support/SMLoc.h"
      26             : #include "llvm/Support/TrailingObjects.h"
      27             : #include "llvm/Support/raw_ostream.h"
      28             : #include <algorithm>
      29             : #include <cassert>
      30             : #include <cstddef>
      31             : #include <cstdint>
      32             : #include <map>
      33             : #include <memory>
      34             : #include <string>
      35             : #include <utility>
      36             : #include <vector>
      37             : 
      38             : namespace llvm {
      39             : 
      40             : class ListRecTy;
      41             : struct MultiClass;
      42             : class Record;
      43             : class RecordKeeper;
      44             : class RecordVal;
      45             : class StringInit;
      46             : 
      47             : //===----------------------------------------------------------------------===//
      48             : //  Type Classes
      49             : //===----------------------------------------------------------------------===//
      50             : 
      51             : class RecTy {
      52             : public:
      53             :   /// \brief Subclass discriminator (for dyn_cast<> et al.)
      54             :   enum RecTyKind {
      55             :     BitRecTyKind,
      56             :     BitsRecTyKind,
      57             :     CodeRecTyKind,
      58             :     IntRecTyKind,
      59             :     StringRecTyKind,
      60             :     ListRecTyKind,
      61             :     DagRecTyKind,
      62             :     RecordRecTyKind
      63             :   };
      64             : 
      65             : private:
      66             :   RecTyKind Kind;
      67             :   ListRecTy *ListTy = nullptr;
      68             : 
      69             : public:
      70      984460 :   RecTy(RecTyKind K) : Kind(K) {}
      71             :   virtual ~RecTy() = default;
      72             : 
      73             :   RecTyKind getRecTyKind() const { return Kind; }
      74             : 
      75             :   virtual std::string getAsString() const = 0;
      76        4630 :   void print(raw_ostream &OS) const { OS << getAsString(); }
      77             :   void dump() const;
      78             : 
      79             :   /// Return true if all values of 'this' type can be converted to the specified
      80             :   /// type.
      81             :   virtual bool typeIsConvertibleTo(const RecTy *RHS) const;
      82             : 
      83             :   /// Returns the type representing list<this>.
      84             :   ListRecTy *getListTy();
      85             : };
      86             : 
      87             : inline raw_ostream &operator<<(raw_ostream &OS, const RecTy &Ty) {
      88        2315 :   Ty.print(OS);
      89             :   return OS;
      90             : }
      91             : 
      92             : /// 'bit' - Represent a single bit
      93         288 : class BitRecTy : public RecTy {
      94             :   static BitRecTy Shared;
      95             : 
      96         288 :   BitRecTy() : RecTy(BitRecTyKind) {}
      97             : 
      98             : public:
      99             :   static bool classof(const RecTy *RT) {
     100   302304527 :     return RT->getRecTyKind() == BitRecTyKind;
     101             :   }
     102             : 
     103             :   static BitRecTy *get() { return &Shared; }
     104             : 
     105          35 :   std::string getAsString() const override { return "bit"; }
     106             : 
     107             :   bool typeIsConvertibleTo(const RecTy *RHS) const override;
     108             : };
     109             : 
     110             : /// 'bits<n>' - Represent a fixed number of bits
     111           0 : class BitsRecTy : public RecTy {
     112             :   unsigned Size;
     113             : 
     114        5008 :   explicit BitsRecTy(unsigned Sz) : RecTy(BitsRecTyKind), Size(Sz) {}
     115             : 
     116             : public:
     117             :   static bool classof(const RecTy *RT) {
     118    50397858 :     return RT->getRecTyKind() == BitsRecTyKind;
     119             :   }
     120             : 
     121             :   static BitsRecTy *get(unsigned Sz);
     122             : 
     123             :   unsigned getNumBits() const { return Size; }
     124             : 
     125             :   std::string getAsString() const override;
     126             : 
     127             :   bool typeIsConvertibleTo(const RecTy *RHS) const override;
     128             : };
     129             : 
     130             : /// 'code' - Represent a code fragment
     131         288 : class CodeRecTy : public RecTy {
     132             :   static CodeRecTy Shared;
     133             : 
     134         288 :   CodeRecTy() : RecTy(CodeRecTyKind) {}
     135             : 
     136             : public:
     137             :   static bool classof(const RecTy *RT) {
     138      873983 :     return RT->getRecTyKind() == CodeRecTyKind;
     139             :   }
     140             : 
     141             :   static CodeRecTy *get() { return &Shared; }
     142             : 
     143           3 :   std::string getAsString() const override { return "code"; }
     144             : };
     145             : 
     146             : /// 'int' - Represent an integer value of no particular size
     147         288 : class IntRecTy : public RecTy {
     148             :   static IntRecTy Shared;
     149             : 
     150         288 :   IntRecTy() : RecTy(IntRecTyKind) {}
     151             : 
     152             : public:
     153             :   static bool classof(const RecTy *RT) {
     154    77775852 :     return RT->getRecTyKind() == IntRecTyKind;
     155             :   }
     156             : 
     157             :   static IntRecTy *get() { return &Shared; }
     158             : 
     159         689 :   std::string getAsString() const override { return "int"; }
     160             : 
     161             :   bool typeIsConvertibleTo(const RecTy *RHS) const override;
     162             : };
     163             : 
     164             : /// 'string' - Represent an string value
     165         288 : class StringRecTy : public RecTy {
     166             :   static StringRecTy Shared;
     167             : 
     168         288 :   StringRecTy() : RecTy(StringRecTyKind) {}
     169             : 
     170             : public:
     171             :   static bool classof(const RecTy *RT) {
     172   106606084 :     return RT->getRecTyKind() == StringRecTyKind ||
     173             :            RT->getRecTyKind() == CodeRecTyKind;
     174             :   }
     175             : 
     176             :   static StringRecTy *get() { return &Shared; }
     177             : 
     178             :   std::string getAsString() const override;
     179             : };
     180             : 
     181             : /// 'list<Ty>' - Represent a list of values, all of which must be of
     182             : /// the specified type.
     183           0 : class ListRecTy : public RecTy {
     184             :   friend ListRecTy *RecTy::getListTy();
     185             : 
     186             :   RecTy *Ty;
     187             : 
     188      377854 :   explicit ListRecTy(RecTy *T) : RecTy(ListRecTyKind), Ty(T) {}
     189             : 
     190             : public:
     191             :   static bool classof(const RecTy *RT) {
     192    32098267 :     return RT->getRecTyKind() == ListRecTyKind;
     193             :   }
     194             : 
     195     1258344 :   static ListRecTy *get(RecTy *T) { return T->getListTy(); }
     196             :   RecTy *getElementType() const { return Ty; }
     197             : 
     198             :   std::string getAsString() const override;
     199             : 
     200             :   bool typeIsConvertibleTo(const RecTy *RHS) const override;
     201             : };
     202             : 
     203             : /// 'dag' - Represent a dag fragment
     204         288 : class DagRecTy : public RecTy {
     205             :   static DagRecTy Shared;
     206             : 
     207         288 :   DagRecTy() : RecTy(DagRecTyKind) {}
     208             : 
     209             : public:
     210             :   static bool classof(const RecTy *RT) {
     211    14905047 :     return RT->getRecTyKind() == DagRecTyKind;
     212             :   }
     213             : 
     214             :   static DagRecTy *get() { return &Shared; }
     215             : 
     216             :   std::string getAsString() const override;
     217             : };
     218             : 
     219             : /// '[classname]' - Represent an instance of a class, such as:
     220             : /// (R32 X = EAX).
     221           0 : class RecordRecTy : public RecTy {
     222             :   friend class Record;
     223             : 
     224             :   Record *Rec;
     225             : 
     226     1583178 :   explicit RecordRecTy(Record *R) : RecTy(RecordRecTyKind), Rec(R) {}
     227             : 
     228             : public:
     229             :   static bool classof(const RecTy *RT) {
     230   119109955 :     return RT->getRecTyKind() == RecordRecTyKind;
     231             :   }
     232             : 
     233             :   static RecordRecTy *get(Record *R);
     234             : 
     235             :   Record *getRecord() const { return Rec; }
     236             : 
     237             :   std::string getAsString() const override;
     238             : 
     239             :   bool typeIsConvertibleTo(const RecTy *RHS) const override;
     240             : };
     241             : 
     242             : /// Find a common type that T1 and T2 convert to.
     243             : /// Return 0 if no such type exists.
     244             : RecTy *resolveTypes(RecTy *T1, RecTy *T2);
     245             : 
     246             : //===----------------------------------------------------------------------===//
     247             : //  Initializer Classes
     248             : //===----------------------------------------------------------------------===//
     249             : 
     250             : class Init {
     251             : protected:
     252             :   /// \brief Discriminator enum (for isa<>, dyn_cast<>, et al.)
     253             :   ///
     254             :   /// This enum is laid out by a preorder traversal of the inheritance
     255             :   /// hierarchy, and does not contain an entry for abstract classes, as per
     256             :   /// the recommendation in docs/HowToSetUpLLVMStyleRTTI.rst.
     257             :   ///
     258             :   /// We also explicitly include "first" and "last" values for each
     259             :   /// interior node of the inheritance tree, to make it easier to read the
     260             :   /// corresponding classof().
     261             :   ///
     262             :   /// We could pack these a bit tighter by not having the IK_FirstXXXInit
     263             :   /// and IK_LastXXXInit be their own values, but that would degrade
     264             :   /// readability for really no benefit.
     265             :   enum InitKind : uint8_t {
     266             :     IK_BitInit,
     267             :     IK_FirstTypedInit,
     268             :     IK_BitsInit,
     269             :     IK_CodeInit,
     270             :     IK_DagInit,
     271             :     IK_DefInit,
     272             :     IK_FieldInit,
     273             :     IK_IntInit,
     274             :     IK_ListInit,
     275             :     IK_FirstOpInit,
     276             :     IK_BinOpInit,
     277             :     IK_TernOpInit,
     278             :     IK_UnOpInit,
     279             :     IK_LastOpInit,
     280             :     IK_StringInit,
     281             :     IK_VarInit,
     282             :     IK_VarListElementInit,
     283             :     IK_LastTypedInit,
     284             :     IK_UnsetInit,
     285             :     IK_VarBitInit
     286             :   };
     287             : 
     288             : private:
     289             :   const InitKind Kind;
     290             : 
     291             : protected:
     292             :   uint8_t Opc; // Used by UnOpInit, BinOpInit, and TernOpInit
     293             : 
     294             : private:
     295             :   virtual void anchor();
     296             : 
     297             : public:
     298             :   InitKind getKind() const { return Kind; }
     299             : 
     300             : protected:
     301    22375391 :   explicit Init(InitKind K, uint8_t Opc = 0) : Kind(K), Opc(Opc) {}
     302             : 
     303             : public:
     304             :   Init(const Init &) = delete;
     305             :   Init &operator=(const Init &) = delete;
     306             :   virtual ~Init() = default;
     307             : 
     308             :   /// This virtual method should be overridden by values that may
     309             :   /// not be completely specified yet.
     310    24466228 :   virtual bool isComplete() const { return true; }
     311             : 
     312             :   /// Print out this value.
     313     7608482 :   void print(raw_ostream &OS) const { OS << getAsString(); }
     314             : 
     315             :   /// Convert this value to a string form.
     316             :   virtual std::string getAsString() const = 0;
     317             :   /// Convert this value to a string form,
     318             :   /// without adding quote markers.  This primaruly affects
     319             :   /// StringInits where we will not surround the string value with
     320             :   /// quotes.
     321      763497 :   virtual std::string getAsUnquotedString() const { return getAsString(); }
     322             : 
     323             :   /// Debugging method that may be called through a debugger, just
     324             :   /// invokes print on stderr.
     325             :   void dump() const;
     326             : 
     327             :   /// This virtual function converts to the appropriate
     328             :   /// Init based on the passed in type.
     329             :   virtual Init *convertInitializerTo(RecTy *Ty) const = 0;
     330             : 
     331             :   /// This method is used to implement the bitrange
     332             :   /// selection operator.  Given an initializer, it selects the specified bits
     333             :   /// out, returning them as a new init of bits type.  If it is not legal to use
     334             :   /// the bit subscript operator on this initializer, return null.
     335           0 :   virtual Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const {
     336           0 :     return nullptr;
     337             :   }
     338             : 
     339             :   /// This method is used to implement the list slice
     340             :   /// selection operator.  Given an initializer, it selects the specified list
     341             :   /// elements, returning them as a new init of list type.  If it is not legal
     342             :   /// to take a slice of this, return null.
     343           0 :   virtual Init *convertInitListSlice(ArrayRef<unsigned> Elements) const {
     344           0 :     return nullptr;
     345             :   }
     346             : 
     347             :   /// This method is used to implement the FieldInit class.
     348             :   /// Implementors of this method should return the type of the named field if
     349             :   /// they are of record type.
     350           0 :   virtual RecTy *getFieldType(StringInit *FieldName) const {
     351           0 :     return nullptr;
     352             :   }
     353             : 
     354             :   /// This method complements getFieldType to return the
     355             :   /// initializer for the specified field.  If getFieldType returns non-null
     356             :   /// this method should return non-null, otherwise it returns null.
     357     3765935 :   virtual Init *getFieldInit(Record &R, const RecordVal *RV,
     358             :                              StringInit *FieldName) const {
     359     3765935 :     return nullptr;
     360             :   }
     361             : 
     362             :   /// This method is used by classes that refer to other
     363             :   /// variables which may not be defined at the time the expression is formed.
     364             :   /// If a value is set for the variable later, this method will be called on
     365             :   /// users of the value to allow the value to propagate out.
     366   598852279 :   virtual Init *resolveReferences(Record &R, const RecordVal *RV) const {
     367   598852279 :     return const_cast<Init *>(this);
     368             :   }
     369             : 
     370             :   /// This method is used to return the initializer for the specified
     371             :   /// bit.
     372             :   virtual Init *getBit(unsigned Bit) const = 0;
     373             : 
     374             :   /// This method is used to retrieve the initializer for bit
     375             :   /// reference. For non-VarBitInit, it simply returns itself.
     376   437795990 :   virtual Init *getBitVar() const { return const_cast<Init*>(this); }
     377             : 
     378             :   /// This method is used to retrieve the bit number of a bit
     379             :   /// reference. For non-VarBitInit, it simply returns 0.
     380     8372032 :   virtual unsigned getBitNum() const { return 0; }
     381             : };
     382             : 
     383             : inline raw_ostream &operator<<(raw_ostream &OS, const Init &I) {
     384     3804241 :   I.print(OS); return OS;
     385             : }
     386             : 
     387             : /// This is the common super-class of types that have a specific,
     388             : /// explicit, type.
     389             : class TypedInit : public Init {
     390             :   RecTy *Ty;
     391             : 
     392             : protected:
     393             :   explicit TypedInit(InitKind K, RecTy *T, uint8_t Opc = 0)
     394    43852002 :     : Init(K, Opc), Ty(T) {}
     395             : 
     396             : public:
     397             :   TypedInit(const TypedInit &) = delete;
     398             :   TypedInit &operator=(const TypedInit &) = delete;
     399             : 
     400             :   static bool classof(const Init *I) {
     401     4629185 :     return I->getKind() >= IK_FirstTypedInit &&
     402             :            I->getKind() <= IK_LastTypedInit;
     403             :   }
     404             : 
     405             :   RecTy *getType() const { return Ty; }
     406             : 
     407             :   Init *convertInitializerTo(RecTy *Ty) const override;
     408             : 
     409             :   Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
     410             :   Init *convertInitListSlice(ArrayRef<unsigned> Elements) const override;
     411             : 
     412             :   /// This method is used to implement the FieldInit class.
     413             :   /// Implementors of this method should return the type of the named field if
     414             :   /// they are of record type.
     415             :   ///
     416             :   RecTy *getFieldType(StringInit *FieldName) const override;
     417             : 
     418             :   /// This method is used to implement
     419             :   /// VarListElementInit::resolveReferences.  If the list element is resolvable
     420             :   /// now, we return the resolved value, otherwise we return null.
     421             :   virtual Init *resolveListElementReference(Record &R, const RecordVal *RV,
     422             :                                             unsigned Elt) const = 0;
     423             : };
     424             : 
     425             : /// '?' - Represents an uninitialized value
     426         288 : class UnsetInit : public Init {
     427         288 :   UnsetInit() : Init(IK_UnsetInit) {}
     428             : 
     429             : public:
     430             :   UnsetInit(const UnsetInit &) = delete;
     431             :   UnsetInit &operator=(const UnsetInit &) = delete;
     432             : 
     433             :   static bool classof(const Init *I) {
     434    70822339 :     return I->getKind() == IK_UnsetInit;
     435             :   }
     436             : 
     437             :   static UnsetInit *get();
     438             : 
     439             :   Init *convertInitializerTo(RecTy *Ty) const override;
     440             : 
     441       68784 :   Init *getBit(unsigned Bit) const override {
     442       68784 :     return const_cast<UnsetInit*>(this);
     443             :   }
     444             : 
     445      264769 :   bool isComplete() const override { return false; }
     446      429315 :   std::string getAsString() const override { return "?"; }
     447             : };
     448             : 
     449             : /// 'true'/'false' - Represent a concrete initializer for a bit.
     450         468 : class BitInit : public Init {
     451             :   bool Value;
     452             : 
     453         936 :   explicit BitInit(bool V) : Init(IK_BitInit), Value(V) {}
     454             : 
     455             : public:
     456             :   BitInit(const BitInit &) = delete;
     457             :   BitInit &operator=(BitInit &) = delete;
     458             : 
     459             :   static bool classof(const Init *I) {
     460    55120213 :     return I->getKind() == IK_BitInit;
     461             :   }
     462             : 
     463             :   static BitInit *get(bool V);
     464             : 
     465             :   bool getValue() const { return Value; }
     466             : 
     467             :   Init *convertInitializerTo(RecTy *Ty) const override;
     468             : 
     469     8292996 :   Init *getBit(unsigned Bit) const override {
     470             :     assert(Bit < 1 && "Bit index out of range!");
     471     8292996 :     return const_cast<BitInit*>(this);
     472             :   }
     473             : 
     474        9954 :   std::string getAsString() const override { return Value ? "1" : "0"; }
     475             : };
     476             : 
     477             : /// '{ a, b, c }' - Represents an initializer for a BitsRecTy value.
     478             : /// It contains a vector of bits, whose size is determined by the type.
     479           0 : class BitsInit final : public TypedInit, public FoldingSetNode,
     480             :                        public TrailingObjects<BitsInit, Init *> {
     481             :   unsigned NumBits;
     482             : 
     483             :   BitsInit(unsigned N)
     484     1722722 :     : TypedInit(IK_BitsInit, BitsRecTy::get(N)), NumBits(N) {}
     485             : 
     486             : public:
     487             :   BitsInit(const BitsInit &) = delete;
     488             :   BitsInit &operator=(const BitsInit &) = delete;
     489             : 
     490             :   // Do not use sized deallocation due to trailing objects.
     491           0 :   void operator delete(void *p) { ::operator delete(p); }
     492             : 
     493             :   static bool classof(const Init *I) {
     494      954951 :     return I->getKind() == IK_BitsInit;
     495             :   }
     496             : 
     497             :   static BitsInit *get(ArrayRef<Init *> Range);
     498             : 
     499             :   void Profile(FoldingSetNodeID &ID) const;
     500             : 
     501             :   unsigned getNumBits() const { return NumBits; }
     502             : 
     503             :   Init *convertInitializerTo(RecTy *Ty) const override;
     504             :   Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
     505             : 
     506     4475755 :   bool isComplete() const override {
     507    38737757 :     for (unsigned i = 0; i != getNumBits(); ++i)
     508    17256154 :       if (!getBit(i)->isComplete()) return false;
     509             :     return true;
     510             :   }
     511             : 
     512             :   bool allInComplete() const {
     513       26601 :     for (unsigned i = 0; i != getNumBits(); ++i)
     514       22305 :       if (getBit(i)->isComplete()) return false;
     515             :     return true;
     516             :   }
     517             : 
     518             :   std::string getAsString() const override;
     519             : 
     520             :   /// This method is used to implement
     521             :   /// VarListElementInit::resolveReferences.  If the list element is resolvable
     522             :   /// now, we return the resolved value, otherwise we return null.
     523           0 :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
     524             :                                     unsigned Elt) const override {
     525           0 :     llvm_unreachable("Illegal element reference off bits<n>");
     526             :   }
     527             : 
     528             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
     529             : 
     530    39569349 :   Init *getBit(unsigned Bit) const override {
     531             :     assert(Bit < NumBits && "Bit index out of range!");
     532   849195074 :     return getTrailingObjects<Init *>()[Bit];
     533             :   }
     534             : };
     535             : 
     536             : /// '7' - Represent an initialization by a literal integer value.
     537           0 : class IntInit : public TypedInit {
     538             :   int64_t Value;
     539             : 
     540             :   explicit IntInit(int64_t V)
     541      115706 :     : TypedInit(IK_IntInit, IntRecTy::get()), Value(V) {}
     542             : 
     543             : public:
     544             :   IntInit(const IntInit &) = delete;
     545             :   IntInit &operator=(const IntInit &) = delete;
     546             : 
     547             :   static bool classof(const Init *I) {
     548    64358475 :     return I->getKind() == IK_IntInit;
     549             :   }
     550             : 
     551             :   static IntInit *get(int64_t V);
     552             : 
     553             :   int64_t getValue() const { return Value; }
     554             : 
     555             :   Init *convertInitializerTo(RecTy *Ty) const override;
     556             :   Init *convertInitializerBitRange(ArrayRef<unsigned> Bits) const override;
     557             : 
     558             :   std::string getAsString() const override;
     559             : 
     560             :   /// This method is used to implement
     561             :   /// VarListElementInit::resolveReferences.  If the list element is resolvable
     562             :   /// now, we return the resolved value, otherwise we return null.
     563           0 :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
     564             :                                     unsigned Elt) const override {
     565           0 :     llvm_unreachable("Illegal element reference off int");
     566             :   }
     567             : 
     568     5739383 :   Init *getBit(unsigned Bit) const override {
     569     5739383 :     return BitInit::get((Value & (1ULL << Bit)) != 0);
     570             :   }
     571             : };
     572             : 
     573             : /// "foo" - Represent an initialization by a string value.
     574           0 : class StringInit : public TypedInit {
     575             :   StringRef Value;
     576             : 
     577             :   explicit StringInit(StringRef V)
     578    26330930 :       : TypedInit(IK_StringInit, StringRecTy::get()), Value(V) {}
     579             : 
     580             : public:
     581             :   StringInit(const StringInit &) = delete;
     582             :   StringInit &operator=(const StringInit &) = delete;
     583             : 
     584             :   static bool classof(const Init *I) {
     585   247511118 :     return I->getKind() == IK_StringInit;
     586             :   }
     587             : 
     588             :   static StringInit *get(StringRef);
     589             : 
     590             :   StringRef getValue() const { return Value; }
     591             : 
     592             :   Init *convertInitializerTo(RecTy *Ty) const override;
     593             : 
     594     2690604 :   std::string getAsString() const override { return "\"" + Value.str() + "\""; }
     595             : 
     596     5745352 :   std::string getAsUnquotedString() const override { return Value; }
     597             : 
     598             :   /// resolveListElementReference - This method is used to implement
     599             :   /// VarListElementInit::resolveReferences.  If the list element is resolvable
     600             :   /// now, we return the resolved value, otherwise we return null.
     601           0 :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
     602             :                                     unsigned Elt) const override {
     603           0 :     llvm_unreachable("Illegal element reference off string");
     604             :   }
     605             : 
     606           0 :   Init *getBit(unsigned Bit) const override {
     607           0 :     llvm_unreachable("Illegal bit reference off string");
     608             :   }
     609             : };
     610             : 
     611           0 : class CodeInit : public TypedInit {
     612             :   StringRef Value;
     613             : 
     614             :   explicit CodeInit(StringRef V)
     615       14035 :       : TypedInit(IK_CodeInit, static_cast<RecTy *>(CodeRecTy::get())),
     616       14035 :         Value(V) {}
     617             : 
     618             : public:
     619             :   CodeInit(const StringInit &) = delete;
     620             :   CodeInit &operator=(const StringInit &) = delete;
     621             : 
     622             :   static bool classof(const Init *I) {
     623          10 :     return I->getKind() == IK_CodeInit;
     624             :   }
     625             : 
     626             :   static CodeInit *get(StringRef);
     627             : 
     628             :   StringRef getValue() const { return Value; }
     629             : 
     630             :   Init *convertInitializerTo(RecTy *Ty) const override;
     631             : 
     632           1 :   std::string getAsString() const override {
     633           3 :     return "[{" + Value.str() + "}]";
     634             :   }
     635             : 
     636          66 :   std::string getAsUnquotedString() const override { return Value; }
     637             : 
     638             :   /// This method is used to implement
     639             :   /// VarListElementInit::resolveReferences.  If the list element is resolvable
     640             :   /// now, we return the resolved value, otherwise we return null.
     641           0 :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
     642             :                                     unsigned Elt) const override {
     643           0 :     llvm_unreachable("Illegal element reference off string");
     644             :   }
     645             : 
     646           0 :   Init *getBit(unsigned Bit) const override {
     647           0 :     llvm_unreachable("Illegal bit reference off string");
     648             :   }
     649             : };
     650             : 
     651             : /// [AL, AH, CL] - Represent a list of defs
     652             : ///
     653           0 : class ListInit final : public TypedInit, public FoldingSetNode,
     654             :                        public TrailingObjects<ListInit, Init *> {
     655             :   unsigned NumValues;
     656             : 
     657             : public:
     658             :   using const_iterator = Init *const *;
     659             : 
     660             : private:
     661             :   explicit ListInit(unsigned N, RecTy *EltTy)
     662     2436098 :     : TypedInit(IK_ListInit, ListRecTy::get(EltTy)), NumValues(N) {}
     663             : 
     664             : public:
     665             :   ListInit(const ListInit &) = delete;
     666             :   ListInit &operator=(const ListInit &) = delete;
     667             : 
     668             :   // Do not use sized deallocation due to trailing objects.
     669           0 :   void operator delete(void *p) { ::operator delete(p); }
     670             : 
     671             :   static bool classof(const Init *I) {
     672    11380314 :     return I->getKind() == IK_ListInit;
     673             :   }
     674             :   static ListInit *get(ArrayRef<Init *> Range, RecTy *EltTy);
     675             : 
     676             :   void Profile(FoldingSetNodeID &ID) const;
     677             : 
     678             :   Init *getElement(unsigned i) const {
     679             :     assert(i < NumValues && "List element index out of range!");
     680     1768501 :     return getTrailingObjects<Init *>()[i];
     681             :   }
     682             : 
     683             :   Record *getElementAsRecord(unsigned i) const;
     684             : 
     685             :   Init *convertInitListSlice(ArrayRef<unsigned> Elements) const override;
     686             : 
     687             :   Init *convertInitializerTo(RecTy *Ty) const override;
     688             : 
     689             :   /// This method is used by classes that refer to other
     690             :   /// variables which may not be defined at the time they expression is formed.
     691             :   /// If a value is set for the variable later, this method will be called on
     692             :   /// users of the value to allow the value to propagate out.
     693             :   ///
     694             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
     695             : 
     696             :   std::string getAsString() const override;
     697             : 
     698             :   ArrayRef<Init*> getValues() const {
     699    99967964 :     return makeArrayRef(getTrailingObjects<Init *>(), NumValues);
     700             :   }
     701             : 
     702             :   const_iterator begin() const { return getTrailingObjects<Init *>(); }
     703     1219382 :   const_iterator end  () const { return begin() + NumValues; }
     704             : 
     705    41456827 :   size_t         size () const { return NumValues;  }
     706         995 :   bool           empty() const { return NumValues == 0; }
     707             : 
     708             :   /// This method is used to implement
     709             :   /// VarListElementInit::resolveReferences.  If the list element is resolvable
     710             :   /// now, we return the resolved value, otherwise we return null.
     711             :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
     712             :                                     unsigned Elt) const override;
     713             : 
     714           0 :   Init *getBit(unsigned Bit) const override {
     715           0 :     llvm_unreachable("Illegal bit reference off list");
     716             :   }
     717             : };
     718             : 
     719             : /// Base class for operators
     720             : ///
     721             : class OpInit : public TypedInit {
     722             : protected:
     723             :   explicit OpInit(InitKind K, RecTy *Type, uint8_t Opc)
     724             :     : TypedInit(K, Type, Opc) {}
     725             : 
     726             : public:
     727             :   OpInit(const OpInit &) = delete;
     728             :   OpInit &operator=(OpInit &) = delete;
     729             : 
     730             :   static bool classof(const Init *I) {
     731        1474 :     return I->getKind() >= IK_FirstOpInit &&
     732             :            I->getKind() <= IK_LastOpInit;
     733             :   }
     734             : 
     735             :   // Clone - Clone this operator, replacing arguments with the new list
     736             :   virtual OpInit *clone(ArrayRef<Init *> Operands) const = 0;
     737             : 
     738             :   virtual unsigned getNumOperands() const = 0;
     739             :   virtual Init *getOperand(unsigned i) const = 0;
     740             : 
     741             :   // Fold - If possible, fold this to a simpler init.  Return this if not
     742             :   // possible to fold.
     743             :   virtual Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const = 0;
     744             : 
     745             :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
     746             :                                     unsigned Elt) const override;
     747             : 
     748             :   Init *getBit(unsigned Bit) const override;
     749             : };
     750             : 
     751             : /// !op (X) - Transform an init.
     752             : ///
     753           0 : class UnOpInit : public OpInit, public FoldingSetNode {
     754             : public:
     755             :   enum UnaryOp : uint8_t { CAST, HEAD, TAIL, EMPTY };
     756             : 
     757             : private:
     758             :   Init *LHS;
     759             : 
     760             :   UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type)
     761      650276 :     : OpInit(IK_UnOpInit, Type, opc), LHS(lhs) {}
     762             : 
     763             : public:
     764             :   UnOpInit(const UnOpInit &) = delete;
     765             :   UnOpInit &operator=(const UnOpInit &) = delete;
     766             : 
     767             :   static bool classof(const Init *I) {
     768             :     return I->getKind() == IK_UnOpInit;
     769             :   }
     770             : 
     771             :   static UnOpInit *get(UnaryOp opc, Init *lhs, RecTy *Type);
     772             : 
     773             :   void Profile(FoldingSetNodeID &ID) const;
     774             : 
     775             :   // Clone - Clone this operator, replacing arguments with the new list
     776           0 :   OpInit *clone(ArrayRef<Init *> Operands) const override {
     777             :     assert(Operands.size() == 1 &&
     778             :            "Wrong number of operands for unary operation");
     779           0 :     return UnOpInit::get(getOpcode(), *Operands.begin(), getType());
     780             :   }
     781             : 
     782           0 :   unsigned getNumOperands() const override { return 1; }
     783             : 
     784           0 :   Init *getOperand(unsigned i) const override {
     785             :     assert(i == 0 && "Invalid operand id for unary operator");
     786           0 :     return getOperand();
     787             :   }
     788             : 
     789             :   UnaryOp getOpcode() const { return (UnaryOp)Opc; }
     790             :   Init *getOperand() const { return LHS; }
     791             : 
     792             :   // Fold - If possible, fold this to a simpler init.  Return this if not
     793             :   // possible to fold.
     794             :   Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
     795             : 
     796             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
     797             : 
     798             :   std::string getAsString() const override;
     799             : };
     800             : 
     801             : /// !op (X, Y) - Combine two inits.
     802           0 : class BinOpInit : public OpInit, public FoldingSetNode {
     803             : public:
     804             :   enum BinaryOp : uint8_t { ADD, AND, OR, SHL, SRA, SRL, LISTCONCAT,
     805             :                             STRCONCAT, CONCAT, EQ };
     806             : 
     807             : private:
     808             :   Init *LHS, *RHS;
     809             : 
     810     2501772 :   BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) :
     811     2501772 :       OpInit(IK_BinOpInit, Type, opc), LHS(lhs), RHS(rhs) {}
     812             : 
     813             : public:
     814             :   BinOpInit(const BinOpInit &) = delete;
     815             :   BinOpInit &operator=(const BinOpInit &) = delete;
     816             : 
     817             :   static bool classof(const Init *I) {
     818     9997678 :     return I->getKind() == IK_BinOpInit;
     819             :   }
     820             : 
     821             :   static BinOpInit *get(BinaryOp opc, Init *lhs, Init *rhs,
     822             :                         RecTy *Type);
     823             : 
     824             :   void Profile(FoldingSetNodeID &ID) const;
     825             : 
     826             :   // Clone - Clone this operator, replacing arguments with the new list
     827          18 :   OpInit *clone(ArrayRef<Init *> Operands) const override {
     828             :     assert(Operands.size() == 2 &&
     829             :            "Wrong number of operands for binary operation");
     830          18 :     return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType());
     831             :   }
     832             : 
     833          36 :   unsigned getNumOperands() const override { return 2; }
     834          84 :   Init *getOperand(unsigned i) const override {
     835          84 :     switch (i) {
     836           0 :     default: llvm_unreachable("Invalid operand id for binary operator");
     837          50 :     case 0: return getLHS();
     838          34 :     case 1: return getRHS();
     839             :     }
     840             :   }
     841             : 
     842             :   BinaryOp getOpcode() const { return (BinaryOp)Opc; }
     843             :   Init *getLHS() const { return LHS; }
     844             :   Init *getRHS() const { return RHS; }
     845             : 
     846             :   // Fold - If possible, fold this to a simpler init.  Return this if not
     847             :   // possible to fold.
     848             :   Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
     849             : 
     850             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
     851             : 
     852             :   std::string getAsString() const override;
     853             : };
     854             : 
     855             : /// !op (X, Y, Z) - Combine two inits.
     856           0 : class TernOpInit : public OpInit, public FoldingSetNode {
     857             : public:
     858             :   enum TernaryOp : uint8_t { SUBST, FOREACH, IF };
     859             : 
     860             : private:
     861             :   Init *LHS, *MHS, *RHS;
     862             : 
     863             :   TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs,
     864      160665 :              RecTy *Type) :
     865      160665 :       OpInit(IK_TernOpInit, Type, opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
     866             : 
     867             : public:
     868             :   TernOpInit(const TernOpInit &) = delete;
     869             :   TernOpInit &operator=(const TernOpInit &) = delete;
     870             : 
     871             :   static bool classof(const Init *I) {
     872      577224 :     return I->getKind() == IK_TernOpInit;
     873             :   }
     874             : 
     875             :   static TernOpInit *get(TernaryOp opc, Init *lhs,
     876             :                          Init *mhs, Init *rhs,
     877             :                          RecTy *Type);
     878             : 
     879             :   void Profile(FoldingSetNodeID &ID) const;
     880             : 
     881             :   // Clone - Clone this operator, replacing arguments with the new list
     882         291 :   OpInit *clone(ArrayRef<Init *> Operands) const override {
     883             :     assert(Operands.size() == 3 &&
     884             :            "Wrong number of operands for ternary operation");
     885         291 :     return TernOpInit::get(getOpcode(), Operands[0], Operands[1], Operands[2],
     886         291 :                            getType());
     887             :   }
     888             : 
     889         582 :   unsigned getNumOperands() const override { return 3; }
     890        2128 :   Init *getOperand(unsigned i) const override {
     891        2128 :     switch (i) {
     892           0 :     default: llvm_unreachable("Invalid operand id for ternary operator");
     893         873 :     case 0: return getLHS();
     894         858 :     case 1: return getMHS();
     895         397 :     case 2: return getRHS();
     896             :     }
     897             :   }
     898             : 
     899             :   TernaryOp getOpcode() const { return (TernaryOp)Opc; }
     900             :   Init *getLHS() const { return LHS; }
     901             :   Init *getMHS() const { return MHS; }
     902             :   Init *getRHS() const { return RHS; }
     903             : 
     904             :   // Fold - If possible, fold this to a simpler init.  Return this if not
     905             :   // possible to fold.
     906             :   Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
     907             : 
     908      218778 :   bool isComplete() const override {
     909      218778 :     return LHS->isComplete() && MHS->isComplete() && RHS->isComplete();
     910             :   }
     911             : 
     912             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
     913             : 
     914             :   std::string getAsString() const override;
     915             : };
     916             : 
     917             : /// 'Opcode' - Represent a reference to an entire variable object.
     918           0 : class VarInit : public TypedInit {
     919             :   Init *VarName;
     920             : 
     921             :   explicit VarInit(Init *VN, RecTy *T)
     922      703054 :       : TypedInit(IK_VarInit, T), VarName(VN) {}
     923             : 
     924             : public:
     925             :   VarInit(const VarInit &) = delete;
     926             :   VarInit &operator=(const VarInit &) = delete;
     927             : 
     928             :   static bool classof(const Init *I) {
     929    19028538 :     return I->getKind() == IK_VarInit;
     930             :   }
     931             : 
     932             :   static VarInit *get(StringRef VN, RecTy *T);
     933             :   static VarInit *get(Init *VN, RecTy *T);
     934             : 
     935             :   StringRef getName() const;
     936             :   Init *getNameInit() const { return VarName; }
     937             : 
     938             :   std::string getNameInitAsString() const {
     939             :     return getNameInit()->getAsUnquotedString();
     940             :   }
     941             : 
     942             :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
     943             :                                     unsigned Elt) const override;
     944             : 
     945             :   RecTy *getFieldType(StringInit *FieldName) const override;
     946             :   Init *getFieldInit(Record &R, const RecordVal *RV,
     947             :                      StringInit *FieldName) const override;
     948             : 
     949             :   /// This method is used by classes that refer to other
     950             :   /// variables which may not be defined at the time they expression is formed.
     951             :   /// If a value is set for the variable later, this method will be called on
     952             :   /// users of the value to allow the value to propagate out.
     953             :   ///
     954             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
     955             : 
     956             :   Init *getBit(unsigned Bit) const override;
     957             : 
     958     1248790 :   std::string getAsString() const override { return getName(); }
     959             : };
     960             : 
     961             : /// Opcode{0} - Represent access to one bit of a variable or field.
     962           0 : class VarBitInit : public Init {
     963             :   TypedInit *TI;
     964             :   unsigned Bit;
     965             : 
     966      897268 :   VarBitInit(TypedInit *T, unsigned B) : Init(IK_VarBitInit), TI(T), Bit(B) {
     967             :     assert(T->getType() &&
     968             :            (isa<IntRecTy>(T->getType()) ||
     969             :             (isa<BitsRecTy>(T->getType()) &&
     970             :              cast<BitsRecTy>(T->getType())->getNumBits() > B)) &&
     971             :            "Illegal VarBitInit expression!");
     972             :   }
     973             : 
     974             : public:
     975             :   VarBitInit(const VarBitInit &) = delete;
     976             :   VarBitInit &operator=(const VarBitInit &) = delete;
     977             : 
     978             :   static bool classof(const Init *I) {
     979    11960585 :     return I->getKind() == IK_VarBitInit;
     980             :   }
     981             : 
     982             :   static VarBitInit *get(TypedInit *T, unsigned B);
     983             : 
     984             :   Init *convertInitializerTo(RecTy *Ty) const override;
     985             : 
     986   304046982 :   Init *getBitVar() const override { return TI; }
     987    47408011 :   unsigned getBitNum() const override { return Bit; }
     988             : 
     989             :   std::string getAsString() const override;
     990             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
     991             : 
     992           0 :   Init *getBit(unsigned B) const override {
     993             :     assert(B < 1 && "Bit index out of range!");
     994           0 :     return const_cast<VarBitInit*>(this);
     995             :   }
     996             : };
     997             : 
     998             : /// List[4] - Represent access to one element of a var or
     999             : /// field.
    1000           0 : class VarListElementInit : public TypedInit {
    1001             :   TypedInit *TI;
    1002             :   unsigned Element;
    1003             : 
    1004             :   VarListElementInit(TypedInit *T, unsigned E)
    1005        2258 :       : TypedInit(IK_VarListElementInit,
    1006             :                   cast<ListRecTy>(T->getType())->getElementType()),
    1007        4516 :         TI(T), Element(E) {
    1008             :     assert(T->getType() && isa<ListRecTy>(T->getType()) &&
    1009             :            "Illegal VarBitInit expression!");
    1010             :   }
    1011             : 
    1012             : public:
    1013             :   VarListElementInit(const VarListElementInit &) = delete;
    1014             :   VarListElementInit &operator=(const VarListElementInit &) = delete;
    1015             : 
    1016             :   static bool classof(const Init *I) {
    1017             :     return I->getKind() == IK_VarListElementInit;
    1018             :   }
    1019             : 
    1020             :   static VarListElementInit *get(TypedInit *T, unsigned E);
    1021             : 
    1022             :   TypedInit *getVariable() const { return TI; }
    1023             :   unsigned getElementNum() const { return Element; }
    1024             : 
    1025             :   /// This method is used to implement
    1026             :   /// VarListElementInit::resolveReferences.  If the list element is resolvable
    1027             :   /// now, we return the resolved value, otherwise we return null.
    1028             :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
    1029             :                                     unsigned Elt) const override;
    1030             : 
    1031             :   std::string getAsString() const override;
    1032             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
    1033             : 
    1034             :   Init *getBit(unsigned Bit) const override;
    1035             : };
    1036             : 
    1037             : /// AL - Represent a reference to a 'def' in the description
    1038           0 : class DefInit : public TypedInit {
    1039             :   friend class Record;
    1040             : 
    1041             :   Record *Def;
    1042             : 
    1043     1583178 :   DefInit(Record *D, RecordRecTy *T) : TypedInit(IK_DefInit, T), Def(D) {}
    1044             : 
    1045             : public:
    1046             :   DefInit(const DefInit &) = delete;
    1047             :   DefInit &operator=(const DefInit &) = delete;
    1048             : 
    1049             :   static bool classof(const Init *I) {
    1050    40922609 :     return I->getKind() == IK_DefInit;
    1051             :   }
    1052             : 
    1053             :   static DefInit *get(Record*);
    1054             : 
    1055             :   Init *convertInitializerTo(RecTy *Ty) const override;
    1056             : 
    1057             :   Record *getDef() const { return Def; }
    1058             : 
    1059             :   //virtual Init *convertInitializerBitRange(ArrayRef<unsigned> Bits);
    1060             : 
    1061             :   RecTy *getFieldType(StringInit *FieldName) const override;
    1062             :   Init *getFieldInit(Record &R, const RecordVal *RV,
    1063             :                      StringInit *FieldName) const override;
    1064             : 
    1065             :   std::string getAsString() const override;
    1066             : 
    1067           0 :   Init *getBit(unsigned Bit) const override {
    1068           0 :     llvm_unreachable("Illegal bit reference off def");
    1069             :   }
    1070             : 
    1071             :   /// This method is used to implement
    1072             :   /// VarListElementInit::resolveReferences.  If the list element is resolvable
    1073             :   /// now, we return the resolved value, otherwise we return null.
    1074           0 :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
    1075             :                                     unsigned Elt) const override {
    1076           0 :     llvm_unreachable("Illegal element reference off def");
    1077             :   }
    1078             : };
    1079             : 
    1080             : /// X.Y - Represent a reference to a subfield of a variable
    1081           0 : class FieldInit : public TypedInit {
    1082             :   Init *Rec;                // Record we are referring to
    1083             :   StringInit *FieldName;    // Field we are accessing
    1084             : 
    1085             :   FieldInit(Init *R, StringInit *FN)
    1086      201472 :       : TypedInit(IK_FieldInit, R->getFieldType(FN)), Rec(R), FieldName(FN) {
    1087             :     assert(getType() && "FieldInit with non-record type!");
    1088             :   }
    1089             : 
    1090             : public:
    1091             :   FieldInit(const FieldInit &) = delete;
    1092             :   FieldInit &operator=(const FieldInit &) = delete;
    1093             : 
    1094             :   static bool classof(const Init *I) {
    1095             :     return I->getKind() == IK_FieldInit;
    1096             :   }
    1097             : 
    1098             :   static FieldInit *get(Init *R, StringInit *FN);
    1099             : 
    1100             :   Init *getBit(unsigned Bit) const override;
    1101             : 
    1102             :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
    1103             :                                     unsigned Elt) const override;
    1104             : 
    1105             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
    1106             : 
    1107         731 :   std::string getAsString() const override {
    1108        3655 :     return Rec->getAsString() + "." + FieldName->getValue().str();
    1109             :   }
    1110             : };
    1111             : 
    1112             : /// (v a, b) - Represent a DAG tree value.  DAG inits are required
    1113             : /// to have at least one value then a (possibly empty) list of arguments.  Each
    1114             : /// argument can have a name associated with it.
    1115           0 : class DagInit final : public TypedInit, public FoldingSetNode,
    1116             :                       public TrailingObjects<DagInit, Init *, StringInit *> {
    1117             :   friend TrailingObjects;
    1118             : 
    1119             :   Init *Val;
    1120             :   StringInit *ValName;
    1121             :   unsigned NumArgs;
    1122             :   unsigned NumArgNames;
    1123             : 
    1124             :   DagInit(Init *V, StringInit *VN, unsigned NumArgs, unsigned NumArgNames)
    1125     2375553 :       : TypedInit(IK_DagInit, DagRecTy::get()), Val(V), ValName(VN),
    1126     2375553 :         NumArgs(NumArgs), NumArgNames(NumArgNames) {}
    1127             : 
    1128    19099865 :   size_t numTrailingObjects(OverloadToken<Init *>) const { return NumArgs; }
    1129             : 
    1130             : public:
    1131             :   DagInit(const DagInit &) = delete;
    1132             :   DagInit &operator=(const DagInit &) = delete;
    1133             : 
    1134             :   static bool classof(const Init *I) {
    1135     3969567 :     return I->getKind() == IK_DagInit;
    1136             :   }
    1137             : 
    1138             :   static DagInit *get(Init *V, StringInit *VN, ArrayRef<Init *> ArgRange,
    1139             :                       ArrayRef<StringInit*> NameRange);
    1140             :   static DagInit *get(Init *V, StringInit *VN,
    1141             :                       ArrayRef<std::pair<Init*, StringInit*>> Args);
    1142             : 
    1143             :   void Profile(FoldingSetNodeID &ID) const;
    1144             : 
    1145             :   Init *convertInitializerTo(RecTy *Ty) const override;
    1146             : 
    1147             :   Init *getOperator() const { return Val; }
    1148             : 
    1149             :   StringInit *getName() const { return ValName; }
    1150             : 
    1151             :   StringRef getNameStr() const {
    1152             :     return ValName ? ValName->getValue() : StringRef();
    1153             :   }
    1154             : 
    1155             :   unsigned getNumArgs() const { return NumArgs; }
    1156             : 
    1157             :   Init *getArg(unsigned Num) const {
    1158             :     assert(Num < NumArgs && "Arg number out of range!");
    1159     4680031 :     return getTrailingObjects<Init *>()[Num];
    1160             :   }
    1161             : 
    1162             :   StringInit *getArgName(unsigned Num) const {
    1163             :     assert(Num < NumArgNames && "Arg number out of range!");
    1164     3709729 :     return getTrailingObjects<StringInit *>()[Num];
    1165             :   }
    1166             : 
    1167             :   StringRef getArgNameStr(unsigned Num) const {
    1168             :     StringInit *Init = getArgName(Num);
    1169     3481310 :     return Init ? Init->getValue() : StringRef();
    1170             :   }
    1171             : 
    1172             :   ArrayRef<Init *> getArgs() const {
    1173    32895065 :     return makeArrayRef(getTrailingObjects<Init *>(), NumArgs);
    1174             :   }
    1175             : 
    1176             :   ArrayRef<StringInit *> getArgNames() const {
    1177     3290324 :     return makeArrayRef(getTrailingObjects<StringInit *>(), NumArgNames);
    1178             :   }
    1179             : 
    1180             :   Init *resolveReferences(Record &R, const RecordVal *RV) const override;
    1181             : 
    1182             :   std::string getAsString() const override;
    1183             : 
    1184             :   using const_arg_iterator = SmallVectorImpl<Init*>::const_iterator;
    1185             :   using const_name_iterator = SmallVectorImpl<StringInit*>::const_iterator;
    1186             : 
    1187             :   inline const_arg_iterator  arg_begin() const { return getArgs().begin(); }
    1188             :   inline const_arg_iterator  arg_end  () const { return getArgs().end(); }
    1189             : 
    1190    32853341 :   inline size_t              arg_size () const { return NumArgs; }
    1191             :   inline bool                arg_empty() const { return NumArgs == 0; }
    1192             : 
    1193             :   inline const_name_iterator name_begin() const { return getArgNames().begin();}
    1194             :   inline const_name_iterator name_end  () const { return getArgNames().end(); }
    1195             : 
    1196             :   inline size_t              name_size () const { return NumArgNames; }
    1197             :   inline bool                name_empty() const { return NumArgNames == 0; }
    1198             : 
    1199           0 :   Init *getBit(unsigned Bit) const override {
    1200           0 :     llvm_unreachable("Illegal bit reference off dag");
    1201             :   }
    1202             : 
    1203           0 :   Init *resolveListElementReference(Record &R, const RecordVal *RV,
    1204             :                                     unsigned Elt) const override {
    1205           0 :     llvm_unreachable("Illegal element reference off dag");
    1206             :   }
    1207             : };
    1208             : 
    1209             : //===----------------------------------------------------------------------===//
    1210             : //  High-Level Classes
    1211             : //===----------------------------------------------------------------------===//
    1212             : 
    1213             : class RecordVal {
    1214             :   friend class Record;
    1215             : 
    1216             :   Init *Name;
    1217             :   PointerIntPair<RecTy *, 1, bool> TyAndPrefix;
    1218             :   Init *Value;
    1219             : 
    1220             : public:
    1221             :   RecordVal(Init *N, RecTy *T, bool P);
    1222             : 
    1223             :   StringRef getName() const;
    1224             :   Init *getNameInit() const { return Name; }
    1225             : 
    1226             :   std::string getNameInitAsString() const {
    1227        2315 :     return getNameInit()->getAsUnquotedString();
    1228             :   }
    1229             : 
    1230             :   bool getPrefix() const { return TyAndPrefix.getInt(); }
    1231             :   RecTy *getType() const { return TyAndPrefix.getPointer(); }
    1232             :   Init *getValue() const { return Value; }
    1233             : 
    1234             :   bool setValue(Init *V) {
    1235   541290457 :     if (V) {
    1236  1082580914 :       Value = V->convertInitializerTo(getType());
    1237   541236555 :       return Value == nullptr;
    1238             :     }
    1239           0 :     Value = nullptr;
    1240             :     return false;
    1241             :   }
    1242             : 
    1243             :   void dump() const;
    1244             :   void print(raw_ostream &OS, bool PrintSem = true) const;
    1245             : };
    1246             : 
    1247        2138 : inline raw_ostream &operator<<(raw_ostream &OS, const RecordVal &RV) {
    1248        2138 :   RV.print(OS << "  ");
    1249        2138 :   return OS;
    1250             : }
    1251             : 
    1252     6528630 : class Record {
    1253             :   static unsigned LastID;
    1254             : 
    1255             :   Init *Name;
    1256             :   // Location where record was instantiated, followed by the location of
    1257             :   // multiclass prototypes used.
    1258             :   SmallVector<SMLoc, 4> Locs;
    1259             :   SmallVector<Init *, 0> TemplateArgs;
    1260             :   SmallVector<RecordVal, 0> Values;
    1261             :   SmallVector<std::pair<Record *, SMRange>, 0> SuperClasses;
    1262             : 
    1263             :   // Tracks Record instances. Not owned by Record.
    1264             :   RecordKeeper &TrackedRecords;
    1265             : 
    1266             :   DefInit *TheInit = nullptr;
    1267             : 
    1268             :   // Unique record ID.
    1269             :   unsigned ID;
    1270             : 
    1271             :   bool IsAnonymous;
    1272             : 
    1273             :   // Class-instance values can be used by other defs.  For example, Struct<i>
    1274             :   // is used here as a template argument to another class:
    1275             :   //
    1276             :   //   multiclass MultiClass<int i> {
    1277             :   //     def Def : Class<Struct<i>>;
    1278             :   //
    1279             :   // These need to get fully resolved before instantiating any other
    1280             :   // definitions that use them (e.g. Def).  However, inside a multiclass they
    1281             :   // can't be immediately resolved so we mark them ResolveFirst to fully
    1282             :   // resolve them later as soon as the multiclass is instantiated.
    1283             :   bool ResolveFirst = false;
    1284             : 
    1285             :   void init();
    1286             :   void checkName();
    1287             : 
    1288             : public:
    1289             :   // Constructs a record.
    1290     3230613 :   explicit Record(Init *N, ArrayRef<SMLoc> locs, RecordKeeper &records,
    1291     3230613 :                   bool Anonymous = false) :
    1292             :     Name(N), Locs(locs.begin(), locs.end()), TrackedRecords(records),
    1293     6461226 :     ID(LastID++), IsAnonymous(Anonymous) {
    1294     3230613 :     init();
    1295     3230613 :   }
    1296             : 
    1297             :   explicit Record(StringRef N, ArrayRef<SMLoc> locs, RecordKeeper &records,
    1298             :                   bool Anonymous = false)
    1299      194577 :     : Record(StringInit::get(N), locs, records, Anonymous) {}
    1300             : 
    1301             :   // When copy-constructing a Record, we must still guarantee a globally unique
    1302             :   // ID number.  Don't copy TheInit either since it's owned by the original
    1303             :   // record. All other fields can be copied normally.
    1304       64186 :   Record(const Record &O) :
    1305       64186 :     Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
    1306             :     Values(O.Values), SuperClasses(O.SuperClasses),
    1307      128372 :     TrackedRecords(O.TrackedRecords), ID(LastID++),
    1308      192558 :     IsAnonymous(O.IsAnonymous), ResolveFirst(O.ResolveFirst) { }
    1309             : 
    1310       21271 :   static unsigned getNewUID() { return LastID++; }
    1311             : 
    1312             :   unsigned getID() const { return ID; }
    1313             : 
    1314             :   StringRef getName() const { return cast<StringInit>(Name)->getValue(); }
    1315             : 
    1316             :   Init *getNameInit() const {
    1317             :     return Name;
    1318             :   }
    1319             : 
    1320             :   const std::string getNameInitAsString() const {
    1321     3262820 :     return getNameInit()->getAsUnquotedString();
    1322             :   }
    1323             : 
    1324             :   void setName(Init *Name);      // Also updates RecordKeeper.
    1325             : 
    1326             :   ArrayRef<SMLoc> getLoc() const { return Locs; }
    1327             : 
    1328             :   /// get the corresponding DefInit.
    1329             :   DefInit *getDefInit();
    1330             : 
    1331             :   ArrayRef<Init *> getTemplateArgs() const {
    1332             :     return TemplateArgs;
    1333             :   }
    1334             : 
    1335             :   ArrayRef<RecordVal> getValues() const { return Values; }
    1336             : 
    1337             :   ArrayRef<std::pair<Record *, SMRange>>  getSuperClasses() const {
    1338             :     return SuperClasses;
    1339             :   }
    1340             : 
    1341             :   bool isTemplateArg(Init *Name) const {
    1342    16700066 :     for (Init *TA : TemplateArgs)
    1343     4407118 :       if (TA == Name) return true;
    1344             :     return false;
    1345             :   }
    1346             : 
    1347             :   const RecordVal *getValue(const Init *Name) const {
    1348 44972170543 :     for (const RecordVal &Val : Values)
    1349 22592725402 :       if (Val.Name == Name) return &Val;
    1350             :     return nullptr;
    1351             :   }
    1352             : 
    1353             :   const RecordVal *getValue(StringRef Name) const {
    1354    54191176 :     return getValue(StringInit::get(Name));
    1355             :   }
    1356             : 
    1357             :   RecordVal *getValue(const Init *Name) {
    1358             :     return const_cast<RecordVal *>(static_cast<const Record *>(this)->getValue(Name));
    1359             :   }
    1360             : 
    1361     2722297 :   RecordVal *getValue(StringRef Name) {
    1362     2722297 :     return const_cast<RecordVal *>(static_cast<const Record *>(this)->getValue(Name));
    1363             :   }
    1364             : 
    1365             :   void addTemplateArg(Init *Name) {
    1366             :     assert(!isTemplateArg(Name) && "Template arg already defined!");
    1367      338551 :     TemplateArgs.push_back(Name);
    1368             :   }
    1369             : 
    1370   102855730 :   void addValue(const RecordVal &RV) {
    1371             :     assert(getValue(RV.getNameInit()) == nullptr && "Value already added!");
    1372   102855730 :     Values.push_back(RV);
    1373   102855730 :     if (Values.size() > 1)
    1374             :       // Keep NAME at the end of the list.  It makes record dumps a
    1375             :       // bit prettier and allows TableGen tests to be written more
    1376             :       // naturally.  Tests can use CHECK-NEXT to look for Record
    1377             :       // fields they expect to see after a def.  They can't do that if
    1378             :       // NAME is the first Record field.
    1379   199250234 :       std::swap(Values[Values.size() - 2], Values[Values.size() - 1]);
    1380   102855730 :   }
    1381             : 
    1382     9372205 :   void removeValue(Init *Name) {
    1383   244189224 :     for (unsigned i = 0, e = Values.size(); i != e; ++i)
    1384   488378448 :       if (Values[i].getNameInit() == Name) {
    1385             :         Values.erase(Values.begin()+i);
    1386     9372205 :         return;
    1387             :       }
    1388           0 :     llvm_unreachable("Cannot remove an entry that does not exist!");
    1389             :   }
    1390             : 
    1391             :   void removeValue(StringRef Name) {
    1392             :     removeValue(StringInit::get(Name));
    1393             :   }
    1394             : 
    1395             :   bool isSubClassOf(const Record *R) const {
    1396   602181329 :     for (const auto &SCPair : SuperClasses)
    1397   307566115 :       if (SCPair.first == R)
    1398             :         return true;
    1399             :     return false;
    1400             :   }
    1401             : 
    1402    75909489 :   bool isSubClassOf(StringRef Name) const {
    1403   335400865 :     for (const auto &SCPair : SuperClasses) {
    1404   153854177 :       if (const auto *SI = dyn_cast<StringInit>(SCPair.first->getNameInit())) {
    1405             :         if (SI->getValue() == Name)
    1406             :           return true;
    1407      616377 :       } else if (SCPair.first->getNameInitAsString() == Name) {
    1408             :         return true;
    1409             :       }
    1410             :     }
    1411             :     return false;
    1412             :   }
    1413             : 
    1414             :   void addSuperClass(Record *R, SMRange Range) {
    1415             :     assert(!isSubClassOf(R) && "Already subclassing record!");
    1416    29098914 :     SuperClasses.push_back(std::make_pair(R, Range));
    1417             :   }
    1418             : 
    1419             :   /// If there are any field references that refer to fields
    1420             :   /// that have been filled in, we can propagate the values now.
    1421     2930205 :   void resolveReferences() { resolveReferencesTo(nullptr); }
    1422             : 
    1423             :   /// If anything in this record refers to RV, replace the
    1424             :   /// reference to RV with the RHS of RV.  If RV is null, we resolve all
    1425             :   /// possible references.
    1426             :   void resolveReferencesTo(const RecordVal *RV);
    1427             : 
    1428             :   RecordKeeper &getRecords() const {
    1429             :     return TrackedRecords;
    1430             :   }
    1431             : 
    1432             :   bool isAnonymous() const {
    1433             :     return IsAnonymous;
    1434             :   }
    1435             : 
    1436             :   bool isResolveFirst() const {
    1437             :     return ResolveFirst;
    1438             :   }
    1439             : 
    1440             :   void setResolveFirst(bool b) {
    1441       11823 :     ResolveFirst = b;
    1442             :   }
    1443             : 
    1444             :   void print(raw_ostream &OS) const;
    1445             :   void dump() const;
    1446             : 
    1447             :   //===--------------------------------------------------------------------===//
    1448             :   // High-level methods useful to tablegen back-ends
    1449             :   //
    1450             : 
    1451             :   /// Return the initializer for a value with the specified name,
    1452             :   /// or throw an exception if the field does not exist.
    1453             :   Init *getValueInit(StringRef FieldName) const;
    1454             : 
    1455             :   /// Return true if the named field is unset.
    1456             :   bool isValueUnset(StringRef FieldName) const {
    1457      235098 :     return isa<UnsetInit>(getValueInit(FieldName));
    1458             :   }
    1459             : 
    1460             :   /// This method looks up the specified field and returns
    1461             :   /// its value as a string, throwing an exception if the field does not exist
    1462             :   /// or if the value is not a string.
    1463             :   StringRef getValueAsString(StringRef FieldName) const;
    1464             : 
    1465             :   /// This method looks up the specified field and returns
    1466             :   /// its value as a BitsInit, throwing an exception if the field does not exist
    1467             :   /// or if the value is not the right type.
    1468             :   BitsInit *getValueAsBitsInit(StringRef FieldName) const;
    1469             : 
    1470             :   /// This method looks up the specified field and returns
    1471             :   /// its value as a ListInit, throwing an exception if the field does not exist
    1472             :   /// or if the value is not the right type.
    1473             :   ListInit *getValueAsListInit(StringRef FieldName) const;
    1474             : 
    1475             :   /// This method looks up the specified field and
    1476             :   /// returns its value as a vector of records, throwing an exception if the
    1477             :   /// field does not exist or if the value is not the right type.
    1478             :   std::vector<Record*> getValueAsListOfDefs(StringRef FieldName) const;
    1479             : 
    1480             :   /// This method looks up the specified field and
    1481             :   /// returns its value as a vector of integers, throwing an exception if the
    1482             :   /// field does not exist or if the value is not the right type.
    1483             :   std::vector<int64_t> getValueAsListOfInts(StringRef FieldName) const;
    1484             : 
    1485             :   /// This method looks up the specified field and
    1486             :   /// returns its value as a vector of strings, throwing an exception if the
    1487             :   /// field does not exist or if the value is not the right type.
    1488             :   std::vector<StringRef> getValueAsListOfStrings(StringRef FieldName) const;
    1489             : 
    1490             :   /// This method looks up the specified field and returns its
    1491             :   /// value as a Record, throwing an exception if the field does not exist or if
    1492             :   /// the value is not the right type.
    1493             :   Record *getValueAsDef(StringRef FieldName) const;
    1494             : 
    1495             :   /// This method looks up the specified field and returns its
    1496             :   /// value as a bit, throwing an exception if the field does not exist or if
    1497             :   /// the value is not the right type.
    1498             :   bool getValueAsBit(StringRef FieldName) const;
    1499             : 
    1500             :   /// This method looks up the specified field and
    1501             :   /// returns its value as a bit. If the field is unset, sets Unset to true and
    1502             :   /// returns false.
    1503             :   bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const;
    1504             : 
    1505             :   /// This method looks up the specified field and returns its
    1506             :   /// value as an int64_t, throwing an exception if the field does not exist or
    1507             :   /// if the value is not the right type.
    1508             :   int64_t getValueAsInt(StringRef FieldName) const;
    1509             : 
    1510             :   /// This method looks up the specified field and returns its
    1511             :   /// value as an Dag, throwing an exception if the field does not exist or if
    1512             :   /// the value is not the right type.
    1513             :   DagInit *getValueAsDag(StringRef FieldName) const;
    1514             : };
    1515             : 
    1516             : raw_ostream &operator<<(raw_ostream &OS, const Record &R);
    1517             : 
    1518       24089 : struct MultiClass {
    1519             :   Record Rec;  // Placeholder for template args and Name.
    1520             :   using RecordVector = std::vector<std::unique_ptr<Record>>;
    1521             :   RecordVector DefPrototypes;
    1522             : 
    1523             :   void dump() const;
    1524             : 
    1525       24173 :   MultiClass(StringRef Name, SMLoc Loc, RecordKeeper &Records) :
    1526       48346 :     Rec(Name, Loc, Records) {}
    1527             : };
    1528             : 
    1529         572 : class RecordKeeper {
    1530             :   using RecordMap = std::map<std::string, std::unique_ptr<Record>>;
    1531             :   RecordMap Classes, Defs;
    1532             : 
    1533             : public:
    1534             :   const RecordMap &getClasses() const { return Classes; }
    1535             :   const RecordMap &getDefs() const { return Defs; }
    1536             : 
    1537     3440868 :   Record *getClass(StringRef Name) const {
    1538     3440868 :     auto I = Classes.find(Name);
    1539     6881736 :     return I == Classes.end() ? nullptr : I->second.get();
    1540             :   }
    1541             : 
    1542    10771515 :   Record *getDef(StringRef Name) const {
    1543    10771515 :     auto I = Defs.find(Name);
    1544    21543030 :     return I == Defs.end() ? nullptr : I->second.get();
    1545             :   }
    1546             : 
    1547      157849 :   void addClass(std::unique_ptr<Record> R) {
    1548      315698 :     bool Ins = Classes.insert(std::make_pair(R->getName(),
    1549             :                                              std::move(R))).second;
    1550             :     (void)Ins;
    1551             :     assert(Ins && "Class already exists");
    1552      157849 :   }
    1553             : 
    1554     2917871 :   void addDef(std::unique_ptr<Record> R) {
    1555     5835742 :     bool Ins = Defs.insert(std::make_pair(R->getName(),
    1556             :                                           std::move(R))).second;
    1557             :     (void)Ins;
    1558             :     assert(Ins && "Record already exists");
    1559     2917871 :   }
    1560             : 
    1561             :   //===--------------------------------------------------------------------===//
    1562             :   // High-level helper methods, useful for tablegen backends...
    1563             : 
    1564             :   /// This method returns all concrete definitions
    1565             :   /// that derive from the specified class name.  A class with the specified
    1566             :   /// name must exist.
    1567             :   std::vector<Record *> getAllDerivedDefinitions(StringRef ClassName) const;
    1568             : 
    1569             :   void dump() const;
    1570             : };
    1571             : 
    1572             : /// Sorting predicate to sort record pointers by name.
    1573             : struct LessRecord {
    1574     1028383 :   bool operator()(const Record *Rec1, const Record *Rec2) const {
    1575     1028383 :     return StringRef(Rec1->getName()).compare_numeric(Rec2->getName()) < 0;
    1576             :   }
    1577             : };
    1578             : 
    1579             : /// Sorting predicate to sort record pointers by their
    1580             : /// unique ID. If you just need a deterministic order, use this, since it
    1581             : /// just compares two `unsigned`; the other sorting predicates require
    1582             : /// string manipulation.
    1583             : struct LessRecordByID {
    1584             :   bool operator()(const Record *LHS, const Record *RHS) const {
    1585   100927993 :     return LHS->getID() < RHS->getID();
    1586             :   }
    1587             : };
    1588             : 
    1589             : /// Sorting predicate to sort record pointers by their
    1590             : /// name field.
    1591             : struct LessRecordFieldName {
    1592       12420 :   bool operator()(const Record *Rec1, const Record *Rec2) const {
    1593       24840 :     return Rec1->getValueAsString("Name") < Rec2->getValueAsString("Name");
    1594             :   }
    1595             : };
    1596             : 
    1597             : struct LessRecordRegister {
    1598    31186764 :   static bool ascii_isdigit(char x) { return x >= '0' && x <= '9'; }
    1599             : 
    1600      802021 :   struct RecordParts {
    1601             :     SmallVector<std::pair< bool, StringRef>, 4> Parts;
    1602             : 
    1603     1604042 :     RecordParts(StringRef Rec) {
    1604     1604042 :       if (Rec.empty())
    1605             :         return;
    1606             : 
    1607             :       size_t Len = 0;
    1608             :       const char *Start = Rec.data();
    1609             :       const char *Curr = Start;
    1610     1604042 :       bool isDigitPart = ascii_isdigit(Curr[0]);
    1611    48047976 :       for (size_t I = 0, E = Rec.size(); I != E; ++I, ++Len) {
    1612    23221967 :         bool isDigit = ascii_isdigit(Curr[I]);
    1613    23221967 :         if (isDigit != isDigitPart) {
    1614    12721510 :           Parts.push_back(std::make_pair(isDigitPart, StringRef(Start, Len)));
    1615             :           Len = 0;
    1616             :           Start = &Curr[I];
    1617     6360755 :           isDigitPart = ascii_isdigit(Curr[I]);
    1618             :         }
    1619             :       }
    1620             :       // Push the last part.
    1621     3208084 :       Parts.push_back(std::make_pair(isDigitPart, StringRef(Start, Len)));
    1622             :     }
    1623             : 
    1624             :     size_t size() { return Parts.size(); }
    1625             : 
    1626             :     std::pair<bool, StringRef> getPart(size_t i) {
    1627             :       assert (i < Parts.size() && "Invalid idx!");
    1628     4059680 :       return Parts[i];
    1629             :     }
    1630             :   };
    1631             : 
    1632      802021 :   bool operator()(const Record *Rec1, const Record *Rec2) const {
    1633      802021 :     RecordParts LHSParts(StringRef(Rec1->getName()));
    1634      802021 :     RecordParts RHSParts(StringRef(Rec2->getName()));
    1635             : 
    1636             :     size_t LHSNumParts = LHSParts.size();
    1637             :     size_t RHSNumParts = RHSParts.size();
    1638             :     assert (LHSNumParts && RHSNumParts && "Expected at least one part!");
    1639             : 
    1640      802021 :     if (LHSNumParts != RHSNumParts)
    1641      149600 :       return LHSNumParts < RHSNumParts;
    1642             : 
    1643             :     // We expect the registers to be of the form [_a-zA-Z]+([0-9]*[_a-zA-Z]*)*.
    1644     3367653 :     for (size_t I = 0, E = LHSNumParts; I < E; I+=2) {
    1645             :       std::pair<bool, StringRef> LHSPart = LHSParts.getPart(I);
    1646             :       std::pair<bool, StringRef> RHSPart = RHSParts.getPart(I);
    1647             :       // Expect even part to always be alpha.
    1648             :       assert (LHSPart.first == false && RHSPart.first == false &&
    1649             :               "Expected both parts to be alpha.");
    1650             :       if (int Res = LHSPart.second.compare(RHSPart.second))
    1651      213595 :         return Res < 0;
    1652             :     }
    1653      482832 :     for (size_t I = 1, E = LHSNumParts; I < E; I+=2) {
    1654             :       std::pair<bool, StringRef> LHSPart = LHSParts.getPart(I);
    1655             :       std::pair<bool, StringRef> RHSPart = RHSParts.getPart(I);
    1656             :       // Expect odd part to always be numeric.
    1657             :       assert (LHSPart.first == true && RHSPart.first == true &&
    1658             :               "Expected both parts to be numeric.");
    1659      458629 :       if (LHSPart.second.size() != RHSPart.second.size())
    1660      522544 :         return LHSPart.second.size() < RHSPart.second.size();
    1661             : 
    1662             :       unsigned LHSVal, RHSVal;
    1663             : 
    1664             :       bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
    1665             :       assert(!LHSFailed && "Unable to convert LHS to integer.");
    1666             :       bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
    1667             :       assert(!RHSFailed && "Unable to convert RHS to integer.");
    1668             : 
    1669      372711 :       if (LHSVal != RHSVal)
    1670      350708 :         return LHSVal < RHSVal;
    1671             :     }
    1672             :     return LHSNumParts < RHSNumParts;
    1673             :   }
    1674             : };
    1675             : 
    1676             : raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK);
    1677             : 
    1678             : /// Return an Init with a qualifier prefix referring
    1679             : /// to CurRec's name.
    1680             : Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
    1681             :                   Init *Name, StringRef Scoper);
    1682             : 
    1683             : } // end namespace llvm
    1684             : 
    1685             : #endif // LLVM_TABLEGEN_RECORD_H

Generated by: LCOV version 1.13