1 //===- llvm/TableGen/Record.h - Classes for Table Records -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the main TableGen data structures, including the TableGen
11 // types, values, and high-level data structures.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TABLEGEN_RECORD_H
16 #define LLVM_TABLEGEN_RECORD_H
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/FoldingSet.h"
20 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/Casting.h"
22 #include "llvm/Support/DataTypes.h"
23 #include "llvm/Support/ErrorHandling.h"
24 #include "llvm/Support/SourceMgr.h"
25 #include "llvm/Support/raw_ostream.h"
36 //===----------------------------------------------------------------------===//
38 //===----------------------------------------------------------------------===//
42 /// \brief Subclass discriminator (for dyn_cast<> et al.)
55 std::unique_ptr<ListRecTy> ListTy;
58 RecTyKind getRecTyKind() const { return Kind; }
60 RecTy(RecTyKind K) : Kind(K), ListTy(nullptr) {}
63 virtual std::string getAsString() const = 0;
64 void print(raw_ostream &OS) const { OS << getAsString(); }
67 /// typeIsConvertibleTo - Return true if all values of 'this' type can be
68 /// converted to the specified type.
69 virtual bool typeIsConvertibleTo(const RecTy *RHS) const;
71 /// getListTy - Returns the type representing list<this>.
72 ListRecTy *getListTy();
75 inline raw_ostream &operator<<(raw_ostream &OS, const RecTy &Ty) {
80 /// BitRecTy - 'bit' - Represent a single bit
82 class BitRecTy : public RecTy {
83 static BitRecTy Shared;
84 BitRecTy() : RecTy(BitRecTyKind) {}
87 static bool classof(const RecTy *RT) {
88 return RT->getRecTyKind() == BitRecTyKind;
91 static BitRecTy *get() { return &Shared; }
93 std::string getAsString() const override { return "bit"; }
95 bool typeIsConvertibleTo(const RecTy *RHS) const override;
98 /// BitsRecTy - 'bits<n>' - Represent a fixed number of bits
100 class BitsRecTy : public RecTy {
102 explicit BitsRecTy(unsigned Sz) : RecTy(BitsRecTyKind), Size(Sz) {}
105 static bool classof(const RecTy *RT) {
106 return RT->getRecTyKind() == BitsRecTyKind;
109 static BitsRecTy *get(unsigned Sz);
111 unsigned getNumBits() const { return Size; }
113 std::string getAsString() const override;
115 bool typeIsConvertibleTo(const RecTy *RHS) const override;
118 /// IntRecTy - 'int' - Represent an integer value of no particular size
120 class IntRecTy : public RecTy {
121 static IntRecTy Shared;
122 IntRecTy() : RecTy(IntRecTyKind) {}
125 static bool classof(const RecTy *RT) {
126 return RT->getRecTyKind() == IntRecTyKind;
129 static IntRecTy *get() { return &Shared; }
131 std::string getAsString() const override { return "int"; }
133 bool typeIsConvertibleTo(const RecTy *RHS) const override;
136 /// StringRecTy - 'string' - Represent an string value
138 class StringRecTy : public RecTy {
139 static StringRecTy Shared;
140 StringRecTy() : RecTy(StringRecTyKind) {}
142 virtual void anchor();
144 static bool classof(const RecTy *RT) {
145 return RT->getRecTyKind() == StringRecTyKind;
148 static StringRecTy *get() { return &Shared; }
150 std::string getAsString() const override { return "string"; }
153 /// ListRecTy - 'list<Ty>' - Represent a list of values, all of which must be of
154 /// the specified type.
156 class ListRecTy : public RecTy {
158 explicit ListRecTy(RecTy *T) : RecTy(ListRecTyKind), Ty(T) {}
159 friend ListRecTy *RecTy::getListTy();
162 static bool classof(const RecTy *RT) {
163 return RT->getRecTyKind() == ListRecTyKind;
166 static ListRecTy *get(RecTy *T) { return T->getListTy(); }
167 RecTy *getElementType() const { return Ty; }
169 std::string getAsString() const override;
171 bool typeIsConvertibleTo(const RecTy *RHS) const override;
174 /// DagRecTy - 'dag' - Represent a dag fragment
176 class DagRecTy : public RecTy {
177 static DagRecTy Shared;
178 DagRecTy() : RecTy(DagRecTyKind) {}
180 virtual void anchor();
182 static bool classof(const RecTy *RT) {
183 return RT->getRecTyKind() == DagRecTyKind;
186 static DagRecTy *get() { return &Shared; }
188 std::string getAsString() const override { return "dag"; }
191 /// RecordRecTy - '[classname]' - Represent an instance of a class, such as:
194 class RecordRecTy : public RecTy {
196 explicit RecordRecTy(Record *R) : RecTy(RecordRecTyKind), Rec(R) {}
200 static bool classof(const RecTy *RT) {
201 return RT->getRecTyKind() == RecordRecTyKind;
204 static RecordRecTy *get(Record *R);
206 Record *getRecord() const { return Rec; }
208 std::string getAsString() const override;
210 bool typeIsConvertibleTo(const RecTy *RHS) const override;
213 /// resolveTypes - Find a common type that T1 and T2 convert to.
214 /// Return 0 if no such type exists.
216 RecTy *resolveTypes(RecTy *T1, RecTy *T2);
218 //===----------------------------------------------------------------------===//
219 // Initializer Classes
220 //===----------------------------------------------------------------------===//
224 /// \brief Discriminator enum (for isa<>, dyn_cast<>, et al.)
226 /// This enum is laid out by a preorder traversal of the inheritance
227 /// hierarchy, and does not contain an entry for abstract classes, as per
228 /// the recommendation in docs/HowToSetUpLLVMStyleRTTI.rst.
230 /// We also explicitly include "first" and "last" values for each
231 /// interior node of the inheritance tree, to make it easier to read the
232 /// corresponding classof().
234 /// We could pack these a bit tighter by not having the IK_FirstXXXInit
235 /// and IK_LastXXXInit be their own values, but that would degrade
236 /// readability for really no benefit.
253 IK_VarListElementInit,
261 Init(const Init &) = delete;
262 Init &operator=(const Init &) = delete;
263 virtual void anchor();
266 InitKind getKind() const { return Kind; }
269 explicit Init(InitKind K) : Kind(K) {}
274 /// isComplete - This virtual method should be overridden by values that may
275 /// not be completely specified yet.
276 virtual bool isComplete() const { return true; }
278 /// print - Print out this value.
279 void print(raw_ostream &OS) const { OS << getAsString(); }
281 /// getAsString - Convert this value to a string form.
282 virtual std::string getAsString() const = 0;
283 /// getAsUnquotedString - Convert this value to a string form,
284 /// without adding quote markers. This primaruly affects
285 /// StringInits where we will not surround the string value with
287 virtual std::string getAsUnquotedString() const { return getAsString(); }
289 /// dump - Debugging method that may be called through a debugger, just
290 /// invokes print on stderr.
293 /// convertInitializerTo - This virtual function converts to the appropriate
294 /// Init based on the passed in type.
295 virtual Init *convertInitializerTo(RecTy *Ty) const = 0;
297 /// convertInitializerBitRange - This method is used to implement the bitrange
298 /// selection operator. Given an initializer, it selects the specified bits
299 /// out, returning them as a new init of bits type. If it is not legal to use
300 /// the bit subscript operator on this initializer, return null.
303 convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
307 /// convertInitListSlice - This method is used to implement the list slice
308 /// selection operator. Given an initializer, it selects the specified list
309 /// elements, returning them as a new init of list type. If it is not legal
310 /// to take a slice of this, return null.
313 convertInitListSlice(const std::vector<unsigned> &Elements) const {
317 /// getFieldType - This method is used to implement the FieldInit class.
318 /// Implementors of this method should return the type of the named field if
319 /// they are of record type.
321 virtual RecTy *getFieldType(const std::string &FieldName) const {
325 /// getFieldInit - This method complements getFieldType to return the
326 /// initializer for the specified field. If getFieldType returns non-null
327 /// this method should return non-null, otherwise it returns null.
329 virtual Init *getFieldInit(Record &R, const RecordVal *RV,
330 const std::string &FieldName) const {
334 /// resolveReferences - This method is used by classes that refer to other
335 /// variables which may not be defined at the time the expression is formed.
336 /// If a value is set for the variable later, this method will be called on
337 /// users of the value to allow the value to propagate out.
339 virtual Init *resolveReferences(Record &R, const RecordVal *RV) const {
340 return const_cast<Init *>(this);
343 /// getBit - This method is used to return the initializer for the specified
345 virtual Init *getBit(unsigned Bit) const = 0;
347 /// getBitVar - This method is used to retrieve the initializer for bit
348 /// reference. For non-VarBitInit, it simply returns itself.
349 virtual Init *getBitVar() const { return const_cast<Init*>(this); }
351 /// getBitNum - This method is used to retrieve the bit number of a bit
352 /// reference. For non-VarBitInit, it simply returns 0.
353 virtual unsigned getBitNum() const { return 0; }
356 inline raw_ostream &operator<<(raw_ostream &OS, const Init &I) {
357 I.print(OS); return OS;
360 /// TypedInit - This is the common super-class of types that have a specific,
363 class TypedInit : public Init {
366 TypedInit(const TypedInit &Other) = delete;
367 TypedInit &operator=(const TypedInit &Other) = delete;
370 explicit TypedInit(InitKind K, RecTy *T) : Init(K), Ty(T) {}
372 // If this is a DefInit we need to delete the RecordRecTy.
373 if (getKind() == IK_DefInit)
378 static bool classof(const Init *I) {
379 return I->getKind() >= IK_FirstTypedInit &&
380 I->getKind() <= IK_LastTypedInit;
382 RecTy *getType() const { return Ty; }
384 Init *convertInitializerTo(RecTy *Ty) const override;
387 convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
389 convertInitListSlice(const std::vector<unsigned> &Elements) const override;
391 /// getFieldType - This method is used to implement the FieldInit class.
392 /// Implementors of this method should return the type of the named field if
393 /// they are of record type.
395 RecTy *getFieldType(const std::string &FieldName) const override;
397 /// resolveListElementReference - This method is used to implement
398 /// VarListElementInit::resolveReferences. If the list element is resolvable
399 /// now, we return the resolved value, otherwise we return null.
400 virtual Init *resolveListElementReference(Record &R, const RecordVal *RV,
401 unsigned Elt) const = 0;
404 /// UnsetInit - ? - Represents an uninitialized value
406 class UnsetInit : public Init {
407 UnsetInit() : Init(IK_UnsetInit) {}
408 UnsetInit(const UnsetInit &) = delete;
409 UnsetInit &operator=(const UnsetInit &Other) = delete;
412 static bool classof(const Init *I) {
413 return I->getKind() == IK_UnsetInit;
415 static UnsetInit *get();
417 Init *convertInitializerTo(RecTy *Ty) const override;
419 Init *getBit(unsigned Bit) const override {
420 return const_cast<UnsetInit*>(this);
423 bool isComplete() const override { return false; }
424 std::string getAsString() const override { return "?"; }
427 /// BitInit - true/false - Represent a concrete initializer for a bit.
429 class BitInit : public Init {
432 explicit BitInit(bool V) : Init(IK_BitInit), Value(V) {}
433 BitInit(const BitInit &Other) = delete;
434 BitInit &operator=(BitInit &Other) = delete;
437 static bool classof(const Init *I) {
438 return I->getKind() == IK_BitInit;
440 static BitInit *get(bool V);
442 bool getValue() const { return Value; }
444 Init *convertInitializerTo(RecTy *Ty) const override;
446 Init *getBit(unsigned Bit) const override {
447 assert(Bit < 1 && "Bit index out of range!");
448 return const_cast<BitInit*>(this);
451 std::string getAsString() const override { return Value ? "1" : "0"; }
454 /// BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
455 /// It contains a vector of bits, whose size is determined by the type.
457 class BitsInit : public TypedInit, public FoldingSetNode {
458 std::vector<Init*> Bits;
460 BitsInit(ArrayRef<Init *> Range)
461 : TypedInit(IK_BitsInit, BitsRecTy::get(Range.size())),
462 Bits(Range.begin(), Range.end()) {}
464 BitsInit(const BitsInit &Other) = delete;
465 BitsInit &operator=(const BitsInit &Other) = delete;
468 static bool classof(const Init *I) {
469 return I->getKind() == IK_BitsInit;
471 static BitsInit *get(ArrayRef<Init *> Range);
473 void Profile(FoldingSetNodeID &ID) const;
475 unsigned getNumBits() const { return Bits.size(); }
477 Init *convertInitializerTo(RecTy *Ty) const override;
479 convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
481 bool isComplete() const override {
482 for (unsigned i = 0; i != getNumBits(); ++i)
483 if (!getBit(i)->isComplete()) return false;
486 bool allInComplete() const {
487 for (unsigned i = 0; i != getNumBits(); ++i)
488 if (getBit(i)->isComplete()) return false;
491 std::string getAsString() const override;
493 /// resolveListElementReference - This method is used to implement
494 /// VarListElementInit::resolveReferences. If the list element is resolvable
495 /// now, we return the resolved value, otherwise we return null.
496 Init *resolveListElementReference(Record &R, const RecordVal *RV,
497 unsigned Elt) const override {
498 llvm_unreachable("Illegal element reference off bits<n>");
501 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
503 Init *getBit(unsigned Bit) const override {
504 assert(Bit < Bits.size() && "Bit index out of range!");
509 /// IntInit - 7 - Represent an initialization by a literal integer value.
511 class IntInit : public TypedInit {
514 explicit IntInit(int64_t V)
515 : TypedInit(IK_IntInit, IntRecTy::get()), Value(V) {}
517 IntInit(const IntInit &Other) = delete;
518 IntInit &operator=(const IntInit &Other) = delete;
521 static bool classof(const Init *I) {
522 return I->getKind() == IK_IntInit;
524 static IntInit *get(int64_t V);
526 int64_t getValue() const { return Value; }
528 Init *convertInitializerTo(RecTy *Ty) const override;
530 convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
532 std::string getAsString() const override;
534 /// resolveListElementReference - This method is used to implement
535 /// VarListElementInit::resolveReferences. If the list element is resolvable
536 /// now, we return the resolved value, otherwise we return null.
537 Init *resolveListElementReference(Record &R, const RecordVal *RV,
538 unsigned Elt) const override {
539 llvm_unreachable("Illegal element reference off int");
542 Init *getBit(unsigned Bit) const override {
543 return BitInit::get((Value & (1ULL << Bit)) != 0);
547 /// StringInit - "foo" - Represent an initialization by a string value.
549 class StringInit : public TypedInit {
552 explicit StringInit(const std::string &V)
553 : TypedInit(IK_StringInit, StringRecTy::get()), Value(V) {}
555 StringInit(const StringInit &Other) = delete;
556 StringInit &operator=(const StringInit &Other) = delete;
559 static bool classof(const Init *I) {
560 return I->getKind() == IK_StringInit;
562 static StringInit *get(StringRef);
564 const std::string &getValue() const { return Value; }
566 Init *convertInitializerTo(RecTy *Ty) const override;
568 std::string getAsString() const override { return "\"" + Value + "\""; }
569 std::string getAsUnquotedString() const override { return Value; }
571 /// resolveListElementReference - This method is used to implement
572 /// VarListElementInit::resolveReferences. If the list element is resolvable
573 /// now, we return the resolved value, otherwise we return null.
574 Init *resolveListElementReference(Record &R, const RecordVal *RV,
575 unsigned Elt) const override {
576 llvm_unreachable("Illegal element reference off string");
579 Init *getBit(unsigned Bit) const override {
580 llvm_unreachable("Illegal bit reference off string");
584 /// ListInit - [AL, AH, CL] - Represent a list of defs
586 class ListInit : public TypedInit, public FoldingSetNode {
587 std::vector<Init*> Values;
590 typedef std::vector<Init*>::const_iterator const_iterator;
593 explicit ListInit(ArrayRef<Init *> Range, RecTy *EltTy)
594 : TypedInit(IK_ListInit, ListRecTy::get(EltTy)),
595 Values(Range.begin(), Range.end()) {}
597 ListInit(const ListInit &Other) = delete;
598 ListInit &operator=(const ListInit &Other) = delete;
601 static bool classof(const Init *I) {
602 return I->getKind() == IK_ListInit;
604 static ListInit *get(ArrayRef<Init *> Range, RecTy *EltTy);
606 void Profile(FoldingSetNodeID &ID) const;
608 unsigned getSize() const { return Values.size(); }
609 Init *getElement(unsigned i) const {
610 assert(i < Values.size() && "List element index out of range!");
614 Record *getElementAsRecord(unsigned i) const;
617 convertInitListSlice(const std::vector<unsigned> &Elements) const override;
619 Init *convertInitializerTo(RecTy *Ty) const override;
621 /// resolveReferences - This method is used by classes that refer to other
622 /// variables which may not be defined at the time they expression is formed.
623 /// If a value is set for the variable later, this method will be called on
624 /// users of the value to allow the value to propagate out.
626 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
628 std::string getAsString() const override;
630 ArrayRef<Init*> getValues() const { return Values; }
632 inline const_iterator begin() const { return Values.begin(); }
633 inline const_iterator end () const { return Values.end(); }
635 inline bool empty() const { return Values.empty(); }
637 /// resolveListElementReference - This method is used to implement
638 /// VarListElementInit::resolveReferences. If the list element is resolvable
639 /// now, we return the resolved value, otherwise we return null.
640 Init *resolveListElementReference(Record &R, const RecordVal *RV,
641 unsigned Elt) const override;
643 Init *getBit(unsigned Bit) const override {
644 llvm_unreachable("Illegal bit reference off list");
648 /// OpInit - Base class for operators
650 class OpInit : public TypedInit {
651 OpInit(const OpInit &Other) = delete;
652 OpInit &operator=(OpInit &Other) = delete;
655 explicit OpInit(InitKind K, RecTy *Type) : TypedInit(K, Type) {}
658 static bool classof(const Init *I) {
659 return I->getKind() >= IK_FirstOpInit &&
660 I->getKind() <= IK_LastOpInit;
662 // Clone - Clone this operator, replacing arguments with the new list
663 virtual OpInit *clone(std::vector<Init *> &Operands) const = 0;
665 virtual int getNumOperands() const = 0;
666 virtual Init *getOperand(int i) const = 0;
668 // Fold - If possible, fold this to a simpler init. Return this if not
670 virtual Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const = 0;
672 Init *resolveListElementReference(Record &R, const RecordVal *RV,
673 unsigned Elt) const override;
675 Init *getBit(unsigned Bit) const override;
678 /// UnOpInit - !op (X) - Transform an init.
680 class UnOpInit : public OpInit {
682 enum UnaryOp { CAST, HEAD, TAIL, EMPTY };
688 UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type)
689 : OpInit(IK_UnOpInit, Type), Opc(opc), LHS(lhs) {}
691 UnOpInit(const UnOpInit &Other) = delete;
692 UnOpInit &operator=(const UnOpInit &Other) = delete;
695 static bool classof(const Init *I) {
696 return I->getKind() == IK_UnOpInit;
698 static UnOpInit *get(UnaryOp opc, Init *lhs, RecTy *Type);
700 // Clone - Clone this operator, replacing arguments with the new list
701 OpInit *clone(std::vector<Init *> &Operands) const override {
702 assert(Operands.size() == 1 &&
703 "Wrong number of operands for unary operation");
704 return UnOpInit::get(getOpcode(), *Operands.begin(), getType());
707 int getNumOperands() const override { return 1; }
708 Init *getOperand(int i) const override {
709 assert(i == 0 && "Invalid operand id for unary operator");
713 UnaryOp getOpcode() const { return Opc; }
714 Init *getOperand() const { return LHS; }
716 // Fold - If possible, fold this to a simpler init. Return this if not
718 Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
720 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
722 std::string getAsString() const override;
725 /// BinOpInit - !op (X, Y) - Combine two inits.
727 class BinOpInit : public OpInit {
729 enum BinaryOp { ADD, AND, SHL, SRA, SRL, LISTCONCAT, STRCONCAT, CONCAT, EQ };
735 BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) :
736 OpInit(IK_BinOpInit, Type), Opc(opc), LHS(lhs), RHS(rhs) {}
738 BinOpInit(const BinOpInit &Other) = delete;
739 BinOpInit &operator=(const BinOpInit &Other) = delete;
742 static bool classof(const Init *I) {
743 return I->getKind() == IK_BinOpInit;
745 static BinOpInit *get(BinaryOp opc, Init *lhs, Init *rhs,
748 // Clone - Clone this operator, replacing arguments with the new list
749 OpInit *clone(std::vector<Init *> &Operands) const override {
750 assert(Operands.size() == 2 &&
751 "Wrong number of operands for binary operation");
752 return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType());
755 int getNumOperands() const override { return 2; }
756 Init *getOperand(int i) const override {
757 assert((i == 0 || i == 1) && "Invalid operand id for binary operator");
765 BinaryOp getOpcode() const { return Opc; }
766 Init *getLHS() const { return LHS; }
767 Init *getRHS() const { return RHS; }
769 // Fold - If possible, fold this to a simpler init. Return this if not
771 Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
773 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
775 std::string getAsString() const override;
778 /// TernOpInit - !op (X, Y, Z) - Combine two inits.
780 class TernOpInit : public OpInit {
782 enum TernaryOp { SUBST, FOREACH, IF };
786 Init *LHS, *MHS, *RHS;
788 TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs,
790 OpInit(IK_TernOpInit, Type), Opc(opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
792 TernOpInit(const TernOpInit &Other) = delete;
793 TernOpInit &operator=(const TernOpInit &Other) = delete;
796 static bool classof(const Init *I) {
797 return I->getKind() == IK_TernOpInit;
799 static TernOpInit *get(TernaryOp opc, Init *lhs,
800 Init *mhs, Init *rhs,
803 // Clone - Clone this operator, replacing arguments with the new list
804 OpInit *clone(std::vector<Init *> &Operands) const override {
805 assert(Operands.size() == 3 &&
806 "Wrong number of operands for ternary operation");
807 return TernOpInit::get(getOpcode(), Operands[0], Operands[1], Operands[2],
811 int getNumOperands() const override { return 3; }
812 Init *getOperand(int i) const override {
813 assert((i == 0 || i == 1 || i == 2) &&
814 "Invalid operand id for ternary operator");
824 TernaryOp getOpcode() const { return Opc; }
825 Init *getLHS() const { return LHS; }
826 Init *getMHS() const { return MHS; }
827 Init *getRHS() const { return RHS; }
829 // Fold - If possible, fold this to a simpler init. Return this if not
831 Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
833 bool isComplete() const override { return false; }
835 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
837 std::string getAsString() const override;
840 /// VarInit - 'Opcode' - Represent a reference to an entire variable object.
842 class VarInit : public TypedInit {
845 explicit VarInit(const std::string &VN, RecTy *T)
846 : TypedInit(IK_VarInit, T), VarName(StringInit::get(VN)) {}
847 explicit VarInit(Init *VN, RecTy *T)
848 : TypedInit(IK_VarInit, T), VarName(VN) {}
850 VarInit(const VarInit &Other) = delete;
851 VarInit &operator=(const VarInit &Other) = delete;
854 static bool classof(const Init *I) {
855 return I->getKind() == IK_VarInit;
857 static VarInit *get(const std::string &VN, RecTy *T);
858 static VarInit *get(Init *VN, RecTy *T);
860 const std::string &getName() const;
861 Init *getNameInit() const { return VarName; }
862 std::string getNameInitAsString() const {
863 return getNameInit()->getAsUnquotedString();
866 Init *resolveListElementReference(Record &R, const RecordVal *RV,
867 unsigned Elt) const override;
869 RecTy *getFieldType(const std::string &FieldName) const override;
870 Init *getFieldInit(Record &R, const RecordVal *RV,
871 const std::string &FieldName) const override;
873 /// resolveReferences - This method is used by classes that refer to other
874 /// variables which may not be defined at the time they expression is formed.
875 /// If a value is set for the variable later, this method will be called on
876 /// users of the value to allow the value to propagate out.
878 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
880 Init *getBit(unsigned Bit) const override;
882 std::string getAsString() const override { return getName(); }
885 /// VarBitInit - Opcode{0} - Represent access to one bit of a variable or field.
887 class VarBitInit : public Init {
891 VarBitInit(TypedInit *T, unsigned B) : Init(IK_VarBitInit), TI(T), Bit(B) {
892 assert(T->getType() &&
893 (isa<IntRecTy>(T->getType()) ||
894 (isa<BitsRecTy>(T->getType()) &&
895 cast<BitsRecTy>(T->getType())->getNumBits() > B)) &&
896 "Illegal VarBitInit expression!");
899 VarBitInit(const VarBitInit &Other) = delete;
900 VarBitInit &operator=(const VarBitInit &Other) = delete;
903 static bool classof(const Init *I) {
904 return I->getKind() == IK_VarBitInit;
906 static VarBitInit *get(TypedInit *T, unsigned B);
908 Init *convertInitializerTo(RecTy *Ty) const override;
910 Init *getBitVar() const override { return TI; }
911 unsigned getBitNum() const override { return Bit; }
913 std::string getAsString() const override;
914 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
916 Init *getBit(unsigned B) const override {
917 assert(B < 1 && "Bit index out of range!");
918 return const_cast<VarBitInit*>(this);
922 /// VarListElementInit - List[4] - Represent access to one element of a var or
924 class VarListElementInit : public TypedInit {
928 VarListElementInit(TypedInit *T, unsigned E)
929 : TypedInit(IK_VarListElementInit,
930 cast<ListRecTy>(T->getType())->getElementType()),
932 assert(T->getType() && isa<ListRecTy>(T->getType()) &&
933 "Illegal VarBitInit expression!");
936 VarListElementInit(const VarListElementInit &Other) = delete;
937 void operator=(const VarListElementInit &Other) = delete;
940 static bool classof(const Init *I) {
941 return I->getKind() == IK_VarListElementInit;
943 static VarListElementInit *get(TypedInit *T, unsigned E);
945 TypedInit *getVariable() const { return TI; }
946 unsigned getElementNum() const { return Element; }
948 /// resolveListElementReference - This method is used to implement
949 /// VarListElementInit::resolveReferences. If the list element is resolvable
950 /// now, we return the resolved value, otherwise we return null.
951 Init *resolveListElementReference(Record &R, const RecordVal *RV,
952 unsigned Elt) const override;
954 std::string getAsString() const override;
955 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
957 Init *getBit(unsigned Bit) const override;
960 /// DefInit - AL - Represent a reference to a 'def' in the description
962 class DefInit : public TypedInit {
965 DefInit(Record *D, RecordRecTy *T) : TypedInit(IK_DefInit, T), Def(D) {}
968 DefInit(const DefInit &Other) = delete;
969 DefInit &operator=(const DefInit &Other) = delete;
972 static bool classof(const Init *I) {
973 return I->getKind() == IK_DefInit;
975 static DefInit *get(Record*);
977 Init *convertInitializerTo(RecTy *Ty) const override;
979 Record *getDef() const { return Def; }
981 //virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
983 RecTy *getFieldType(const std::string &FieldName) const override;
984 Init *getFieldInit(Record &R, const RecordVal *RV,
985 const std::string &FieldName) const override;
987 std::string getAsString() const override;
989 Init *getBit(unsigned Bit) const override {
990 llvm_unreachable("Illegal bit reference off def");
993 /// resolveListElementReference - This method is used to implement
994 /// VarListElementInit::resolveReferences. If the list element is resolvable
995 /// now, we return the resolved value, otherwise we return null.
996 Init *resolveListElementReference(Record &R, const RecordVal *RV,
997 unsigned Elt) const override {
998 llvm_unreachable("Illegal element reference off def");
1002 /// FieldInit - X.Y - Represent a reference to a subfield of a variable
1004 class FieldInit : public TypedInit {
1005 Init *Rec; // Record we are referring to
1006 std::string FieldName; // Field we are accessing
1008 FieldInit(Init *R, const std::string &FN)
1009 : TypedInit(IK_FieldInit, R->getFieldType(FN)), Rec(R), FieldName(FN) {
1010 assert(getType() && "FieldInit with non-record type!");
1013 FieldInit(const FieldInit &Other) = delete;
1014 FieldInit &operator=(const FieldInit &Other) = delete;
1017 static bool classof(const Init *I) {
1018 return I->getKind() == IK_FieldInit;
1020 static FieldInit *get(Init *R, const std::string &FN);
1021 static FieldInit *get(Init *R, const Init *FN);
1023 Init *getBit(unsigned Bit) const override;
1025 Init *resolveListElementReference(Record &R, const RecordVal *RV,
1026 unsigned Elt) const override;
1028 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
1030 std::string getAsString() const override {
1031 return Rec->getAsString() + "." + FieldName;
1035 /// DagInit - (v a, b) - Represent a DAG tree value. DAG inits are required
1036 /// to have at least one value then a (possibly empty) list of arguments. Each
1037 /// argument can have a name associated with it.
1039 class DagInit : public TypedInit, public FoldingSetNode {
1041 std::string ValName;
1042 std::vector<Init*> Args;
1043 std::vector<std::string> ArgNames;
1045 DagInit(Init *V, const std::string &VN,
1046 ArrayRef<Init *> ArgRange,
1047 ArrayRef<std::string> NameRange)
1048 : TypedInit(IK_DagInit, DagRecTy::get()), Val(V), ValName(VN),
1049 Args(ArgRange.begin(), ArgRange.end()),
1050 ArgNames(NameRange.begin(), NameRange.end()) {}
1052 DagInit(const DagInit &Other) = delete;
1053 DagInit &operator=(const DagInit &Other) = delete;
1056 static bool classof(const Init *I) {
1057 return I->getKind() == IK_DagInit;
1059 static DagInit *get(Init *V, const std::string &VN,
1060 ArrayRef<Init *> ArgRange,
1061 ArrayRef<std::string> NameRange);
1062 static DagInit *get(Init *V, const std::string &VN,
1064 std::pair<Init*, std::string> > &args);
1066 void Profile(FoldingSetNodeID &ID) const;
1068 Init *convertInitializerTo(RecTy *Ty) const override;
1070 Init *getOperator() const { return Val; }
1072 const std::string &getName() const { return ValName; }
1074 unsigned getNumArgs() const { return Args.size(); }
1075 Init *getArg(unsigned Num) const {
1076 assert(Num < Args.size() && "Arg number out of range!");
1079 const std::string &getArgName(unsigned Num) const {
1080 assert(Num < ArgNames.size() && "Arg number out of range!");
1081 return ArgNames[Num];
1084 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
1086 std::string getAsString() const override;
1088 typedef std::vector<Init*>::const_iterator const_arg_iterator;
1089 typedef std::vector<std::string>::const_iterator const_name_iterator;
1091 inline const_arg_iterator arg_begin() const { return Args.begin(); }
1092 inline const_arg_iterator arg_end () const { return Args.end(); }
1094 inline size_t arg_size () const { return Args.size(); }
1095 inline bool arg_empty() const { return Args.empty(); }
1097 inline const_name_iterator name_begin() const { return ArgNames.begin(); }
1098 inline const_name_iterator name_end () const { return ArgNames.end(); }
1100 inline size_t name_size () const { return ArgNames.size(); }
1101 inline bool name_empty() const { return ArgNames.empty(); }
1103 Init *getBit(unsigned Bit) const override {
1104 llvm_unreachable("Illegal bit reference off dag");
1107 Init *resolveListElementReference(Record &R, const RecordVal *RV,
1108 unsigned Elt) const override {
1109 llvm_unreachable("Illegal element reference off dag");
1113 //===----------------------------------------------------------------------===//
1114 // High-Level Classes
1115 //===----------------------------------------------------------------------===//
1124 RecordVal(Init *N, RecTy *T, unsigned P);
1125 RecordVal(const std::string &N, RecTy *T, unsigned P);
1127 const std::string &getName() const;
1128 const Init *getNameInit() const { return Name; }
1129 std::string getNameInitAsString() const {
1130 return getNameInit()->getAsUnquotedString();
1133 unsigned getPrefix() const { return Prefix; }
1134 RecTy *getType() const { return Ty; }
1135 Init *getValue() const { return Value; }
1137 bool setValue(Init *V) {
1139 Value = V->convertInitializerTo(Ty);
1140 return Value == nullptr;
1147 void print(raw_ostream &OS, bool PrintSem = true) const;
1150 inline raw_ostream &operator<<(raw_ostream &OS, const RecordVal &RV) {
1151 RV.print(OS << " ");
1156 static unsigned LastID;
1158 // Unique record ID.
1161 // Location where record was instantiated, followed by the location of
1162 // multiclass prototypes used.
1163 SmallVector<SMLoc, 4> Locs;
1164 std::vector<Init *> TemplateArgs;
1165 std::vector<RecordVal> Values;
1166 std::vector<Record *> SuperClasses;
1167 std::vector<SMRange> SuperClassRanges;
1169 // Tracks Record instances. Not owned by Record.
1170 RecordKeeper &TrackedRecords;
1175 // Class-instance values can be used by other defs. For example, Struct<i>
1176 // is used here as a template argument to another class:
1178 // multiclass MultiClass<int i> {
1179 // def Def : Class<Struct<i>>;
1181 // These need to get fully resolved before instantiating any other
1182 // definitions that usie them (e.g. Def). However, inside a multiclass they
1183 // can't be immediately resolved so we mark them ResolveFirst to fully
1184 // resolve them later as soon as the multiclass is instantiated.
1191 // Constructs a record.
1192 explicit Record(const std::string &N, ArrayRef<SMLoc> locs,
1193 RecordKeeper &records, bool Anonymous = false) :
1194 ID(LastID++), Name(StringInit::get(N)), Locs(locs.begin(), locs.end()),
1195 TrackedRecords(records), TheInit(nullptr), IsAnonymous(Anonymous),
1196 ResolveFirst(false) {
1199 explicit Record(Init *N, ArrayRef<SMLoc> locs, RecordKeeper &records,
1200 bool Anonymous = false) :
1201 ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
1202 TrackedRecords(records), TheInit(nullptr), IsAnonymous(Anonymous),
1203 ResolveFirst(false) {
1207 // When copy-constructing a Record, we must still guarantee a globally unique
1208 // ID number. All other fields can be copied normally.
1209 Record(const Record &O) :
1210 ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
1211 Values(O.Values), SuperClasses(O.SuperClasses),
1212 SuperClassRanges(O.SuperClassRanges), TrackedRecords(O.TrackedRecords),
1213 TheInit(O.TheInit), IsAnonymous(O.IsAnonymous),
1214 ResolveFirst(O.ResolveFirst) { }
1216 static unsigned getNewUID() { return LastID++; }
1218 unsigned getID() const { return ID; }
1220 const std::string &getName() const;
1221 Init *getNameInit() const {
1224 const std::string getNameInitAsString() const {
1225 return getNameInit()->getAsUnquotedString();
1228 void setName(Init *Name); // Also updates RecordKeeper.
1229 void setName(const std::string &Name); // Also updates RecordKeeper.
1231 ArrayRef<SMLoc> getLoc() const { return Locs; }
1233 /// get the corresponding DefInit.
1234 DefInit *getDefInit();
1236 const std::vector<Init *> &getTemplateArgs() const {
1237 return TemplateArgs;
1239 const std::vector<RecordVal> &getValues() const { return Values; }
1240 const std::vector<Record*> &getSuperClasses() const { return SuperClasses; }
1241 ArrayRef<SMRange> getSuperClassRanges() const { return SuperClassRanges; }
1243 bool isTemplateArg(Init *Name) const {
1244 for (unsigned i = 0, e = TemplateArgs.size(); i != e; ++i)
1245 if (TemplateArgs[i] == Name) return true;
1248 bool isTemplateArg(StringRef Name) const {
1249 return isTemplateArg(StringInit::get(Name));
1252 const RecordVal *getValue(const Init *Name) const {
1253 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1254 if (Values[i].getNameInit() == Name) return &Values[i];
1257 const RecordVal *getValue(StringRef Name) const {
1258 return getValue(StringInit::get(Name));
1260 RecordVal *getValue(const Init *Name) {
1261 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1262 if (Values[i].getNameInit() == Name) return &Values[i];
1265 RecordVal *getValue(StringRef Name) {
1266 return getValue(StringInit::get(Name));
1269 void addTemplateArg(Init *Name) {
1270 assert(!isTemplateArg(Name) && "Template arg already defined!");
1271 TemplateArgs.push_back(Name);
1273 void addTemplateArg(StringRef Name) {
1274 addTemplateArg(StringInit::get(Name));
1277 void addValue(const RecordVal &RV) {
1278 assert(getValue(RV.getNameInit()) == nullptr && "Value already added!");
1279 Values.push_back(RV);
1280 if (Values.size() > 1)
1281 // Keep NAME at the end of the list. It makes record dumps a
1282 // bit prettier and allows TableGen tests to be written more
1283 // naturally. Tests can use CHECK-NEXT to look for Record
1284 // fields they expect to see after a def. They can't do that if
1285 // NAME is the first Record field.
1286 std::swap(Values[Values.size() - 2], Values[Values.size() - 1]);
1289 void removeValue(Init *Name) {
1290 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1291 if (Values[i].getNameInit() == Name) {
1292 Values.erase(Values.begin()+i);
1295 llvm_unreachable("Cannot remove an entry that does not exist!");
1298 void removeValue(StringRef Name) {
1299 removeValue(StringInit::get(Name));
1302 bool isSubClassOf(const Record *R) const {
1303 for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
1304 if (SuperClasses[i] == R)
1309 bool isSubClassOf(StringRef Name) const {
1310 for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
1311 if (SuperClasses[i]->getNameInitAsString() == Name)
1316 void addSuperClass(Record *R, SMRange Range) {
1317 assert(!isSubClassOf(R) && "Already subclassing record!");
1318 SuperClasses.push_back(R);
1319 SuperClassRanges.push_back(Range);
1322 /// resolveReferences - If there are any field references that refer to fields
1323 /// that have been filled in, we can propagate the values now.
1325 void resolveReferences() { resolveReferencesTo(nullptr); }
1327 /// resolveReferencesTo - If anything in this record refers to RV, replace the
1328 /// reference to RV with the RHS of RV. If RV is null, we resolve all
1329 /// possible references.
1330 void resolveReferencesTo(const RecordVal *RV);
1332 RecordKeeper &getRecords() const {
1333 return TrackedRecords;
1336 bool isAnonymous() const {
1340 bool isResolveFirst() const {
1341 return ResolveFirst;
1344 void setResolveFirst(bool b) {
1350 //===--------------------------------------------------------------------===//
1351 // High-level methods useful to tablegen back-ends
1354 /// getValueInit - Return the initializer for a value with the specified name,
1355 /// or throw an exception if the field does not exist.
1357 Init *getValueInit(StringRef FieldName) const;
1359 /// Return true if the named field is unset.
1360 bool isValueUnset(StringRef FieldName) const {
1361 return getValueInit(FieldName) == UnsetInit::get();
1364 /// getValueAsString - This method looks up the specified field and returns
1365 /// its value as a string, throwing an exception if the field does not exist
1366 /// or if the value is not a string.
1368 std::string getValueAsString(StringRef FieldName) const;
1370 /// getValueAsBitsInit - This method looks up the specified field and returns
1371 /// its value as a BitsInit, throwing an exception if the field does not exist
1372 /// or if the value is not the right type.
1374 BitsInit *getValueAsBitsInit(StringRef FieldName) const;
1376 /// getValueAsListInit - This method looks up the specified field and returns
1377 /// its value as a ListInit, throwing an exception if the field does not exist
1378 /// or if the value is not the right type.
1380 ListInit *getValueAsListInit(StringRef FieldName) const;
1382 /// getValueAsListOfDefs - This method looks up the specified field and
1383 /// returns its value as a vector of records, throwing an exception if the
1384 /// field does not exist or if the value is not the right type.
1386 std::vector<Record*> getValueAsListOfDefs(StringRef FieldName) const;
1388 /// getValueAsListOfInts - This method looks up the specified field and
1389 /// returns its value as a vector of integers, throwing an exception if the
1390 /// field does not exist or if the value is not the right type.
1392 std::vector<int64_t> getValueAsListOfInts(StringRef FieldName) const;
1394 /// getValueAsListOfStrings - This method looks up the specified field and
1395 /// returns its value as a vector of strings, throwing an exception if the
1396 /// field does not exist or if the value is not the right type.
1398 std::vector<std::string> getValueAsListOfStrings(StringRef FieldName) const;
1400 /// getValueAsDef - This method looks up the specified field and returns its
1401 /// value as a Record, throwing an exception if the field does not exist or if
1402 /// the value is not the right type.
1404 Record *getValueAsDef(StringRef FieldName) const;
1406 /// getValueAsBit - This method looks up the specified field and returns its
1407 /// value as a bit, throwing an exception if the field does not exist or if
1408 /// the value is not the right type.
1410 bool getValueAsBit(StringRef FieldName) const;
1412 /// getValueAsBitOrUnset - This method looks up the specified field and
1413 /// returns its value as a bit. If the field is unset, sets Unset to true and
1416 bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const;
1418 /// getValueAsInt - This method looks up the specified field and returns its
1419 /// value as an int64_t, throwing an exception if the field does not exist or
1420 /// if the value is not the right type.
1422 int64_t getValueAsInt(StringRef FieldName) const;
1424 /// getValueAsDag - This method looks up the specified field and returns its
1425 /// value as an Dag, throwing an exception if the field does not exist or if
1426 /// the value is not the right type.
1428 DagInit *getValueAsDag(StringRef FieldName) const;
1431 raw_ostream &operator<<(raw_ostream &OS, const Record &R);
1434 Record Rec; // Placeholder for template args and Name.
1435 typedef std::vector<std::unique_ptr<Record>> RecordVector;
1436 RecordVector DefPrototypes;
1440 MultiClass(const std::string &Name, SMLoc Loc, RecordKeeper &Records) :
1441 Rec(Name, Loc, Records) {}
1444 class RecordKeeper {
1445 typedef std::map<std::string, std::unique_ptr<Record>> RecordMap;
1446 RecordMap Classes, Defs;
1449 const RecordMap &getClasses() const { return Classes; }
1450 const RecordMap &getDefs() const { return Defs; }
1452 Record *getClass(const std::string &Name) const {
1453 auto I = Classes.find(Name);
1454 return I == Classes.end() ? nullptr : I->second.get();
1456 Record *getDef(const std::string &Name) const {
1457 auto I = Defs.find(Name);
1458 return I == Defs.end() ? nullptr : I->second.get();
1460 void addClass(std::unique_ptr<Record> R) {
1461 bool Ins = Classes.insert(std::make_pair(R->getName(),
1462 std::move(R))).second;
1464 assert(Ins && "Class already exists");
1466 void addDef(std::unique_ptr<Record> R) {
1467 bool Ins = Defs.insert(std::make_pair(R->getName(),
1468 std::move(R))).second;
1470 assert(Ins && "Record already exists");
1473 //===--------------------------------------------------------------------===//
1474 // High-level helper methods, useful for tablegen backends...
1476 /// getAllDerivedDefinitions - This method returns all concrete definitions
1477 /// that derive from the specified class name. If a class with the specified
1478 /// name does not exist, an exception is thrown.
1479 std::vector<Record*>
1480 getAllDerivedDefinitions(const std::string &ClassName) const;
1485 /// LessRecord - Sorting predicate to sort record pointers by name.
1488 bool operator()(const Record *Rec1, const Record *Rec2) const {
1489 return StringRef(Rec1->getName()).compare_numeric(Rec2->getName()) < 0;
1493 /// LessRecordByID - Sorting predicate to sort record pointers by their
1494 /// unique ID. If you just need a deterministic order, use this, since it
1495 /// just compares two `unsigned`; the other sorting predicates require
1496 /// string manipulation.
1497 struct LessRecordByID {
1498 bool operator()(const Record *LHS, const Record *RHS) const {
1499 return LHS->getID() < RHS->getID();
1503 /// LessRecordFieldName - Sorting predicate to sort record pointers by their
1506 struct LessRecordFieldName {
1507 bool operator()(const Record *Rec1, const Record *Rec2) const {
1508 return Rec1->getValueAsString("Name") < Rec2->getValueAsString("Name");
1512 struct LessRecordRegister {
1513 static size_t min(size_t a, size_t b) { return a < b ? a : b; }
1514 static bool ascii_isdigit(char x) { return x >= '0' && x <= '9'; }
1516 struct RecordParts {
1517 SmallVector<std::pair< bool, StringRef>, 4> Parts;
1519 RecordParts(StringRef Rec) {
1524 const char *Start = Rec.data();
1525 const char *Curr = Start;
1526 bool isDigitPart = ascii_isdigit(Curr[0]);
1527 for (size_t I = 0, E = Rec.size(); I != E; ++I, ++Len) {
1528 bool isDigit = ascii_isdigit(Curr[I]);
1529 if (isDigit != isDigitPart) {
1530 Parts.push_back(std::make_pair(isDigitPart, StringRef(Start, Len)));
1533 isDigitPart = ascii_isdigit(Curr[I]);
1536 // Push the last part.
1537 Parts.push_back(std::make_pair(isDigitPart, StringRef(Start, Len)));
1540 size_t size() { return Parts.size(); }
1542 std::pair<bool, StringRef> getPart(size_t i) {
1543 assert (i < Parts.size() && "Invalid idx!");
1548 bool operator()(const Record *Rec1, const Record *Rec2) const {
1549 RecordParts LHSParts(StringRef(Rec1->getName()));
1550 RecordParts RHSParts(StringRef(Rec2->getName()));
1552 size_t LHSNumParts = LHSParts.size();
1553 size_t RHSNumParts = RHSParts.size();
1554 assert (LHSNumParts && RHSNumParts && "Expected at least one part!");
1556 if (LHSNumParts != RHSNumParts)
1557 return LHSNumParts < RHSNumParts;
1559 // We expect the registers to be of the form [_a-zA-z]+([0-9]*[_a-zA-Z]*)*.
1560 for (size_t I = 0, E = LHSNumParts; I < E; I+=2) {
1561 std::pair<bool, StringRef> LHSPart = LHSParts.getPart(I);
1562 std::pair<bool, StringRef> RHSPart = RHSParts.getPart(I);
1563 // Expect even part to always be alpha.
1564 assert (LHSPart.first == false && RHSPart.first == false &&
1565 "Expected both parts to be alpha.");
1566 if (int Res = LHSPart.second.compare(RHSPart.second))
1569 for (size_t I = 1, E = LHSNumParts; I < E; I+=2) {
1570 std::pair<bool, StringRef> LHSPart = LHSParts.getPart(I);
1571 std::pair<bool, StringRef> RHSPart = RHSParts.getPart(I);
1572 // Expect odd part to always be numeric.
1573 assert (LHSPart.first == true && RHSPart.first == true &&
1574 "Expected both parts to be numeric.");
1575 if (LHSPart.second.size() != RHSPart.second.size())
1576 return LHSPart.second.size() < RHSPart.second.size();
1578 unsigned LHSVal, RHSVal;
1580 bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
1581 assert(!LHSFailed && "Unable to convert LHS to integer.");
1582 bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
1583 assert(!RHSFailed && "Unable to convert RHS to integer.");
1585 if (LHSVal != RHSVal)
1586 return LHSVal < RHSVal;
1588 return LHSNumParts < RHSNumParts;
1592 raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK);
1594 /// QualifyName - Return an Init with a qualifier prefix referring
1595 /// to CurRec's name.
1596 Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
1597 Init *Name, const std::string &Scoper);
1599 /// QualifyName - Return an Init with a qualifier prefix referring
1600 /// to CurRec's name.
1601 Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
1602 const std::string &Name, const std::string &Scoper);
1604 } // End llvm namespace