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) {}
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) {}
143 static bool classof(const RecTy *RT) {
144 return RT->getRecTyKind() == StringRecTyKind;
147 static StringRecTy *get() { return &Shared; }
149 std::string getAsString() const override;
152 /// ListRecTy - 'list<Ty>' - Represent a list of values, all of which must be of
153 /// the specified type.
155 class ListRecTy : public RecTy {
157 explicit ListRecTy(RecTy *T) : RecTy(ListRecTyKind), Ty(T) {}
158 friend ListRecTy *RecTy::getListTy();
161 static bool classof(const RecTy *RT) {
162 return RT->getRecTyKind() == ListRecTyKind;
165 static ListRecTy *get(RecTy *T) { return T->getListTy(); }
166 RecTy *getElementType() const { return Ty; }
168 std::string getAsString() const override;
170 bool typeIsConvertibleTo(const RecTy *RHS) const override;
173 /// DagRecTy - 'dag' - Represent a dag fragment
175 class DagRecTy : public RecTy {
176 static DagRecTy Shared;
177 DagRecTy() : RecTy(DagRecTyKind) {}
180 static bool classof(const RecTy *RT) {
181 return RT->getRecTyKind() == DagRecTyKind;
184 static DagRecTy *get() { return &Shared; }
186 std::string getAsString() const override;
189 /// RecordRecTy - '[classname]' - Represent an instance of a class, such as:
192 class RecordRecTy : public RecTy {
194 explicit RecordRecTy(Record *R) : RecTy(RecordRecTyKind), Rec(R) {}
198 static bool classof(const RecTy *RT) {
199 return RT->getRecTyKind() == RecordRecTyKind;
202 static RecordRecTy *get(Record *R);
204 Record *getRecord() const { return Rec; }
206 std::string getAsString() const override;
208 bool typeIsConvertibleTo(const RecTy *RHS) const override;
211 /// resolveTypes - Find a common type that T1 and T2 convert to.
212 /// Return 0 if no such type exists.
214 RecTy *resolveTypes(RecTy *T1, RecTy *T2);
216 //===----------------------------------------------------------------------===//
217 // Initializer Classes
218 //===----------------------------------------------------------------------===//
222 /// \brief Discriminator enum (for isa<>, dyn_cast<>, et al.)
224 /// This enum is laid out by a preorder traversal of the inheritance
225 /// hierarchy, and does not contain an entry for abstract classes, as per
226 /// the recommendation in docs/HowToSetUpLLVMStyleRTTI.rst.
228 /// We also explicitly include "first" and "last" values for each
229 /// interior node of the inheritance tree, to make it easier to read the
230 /// corresponding classof().
232 /// We could pack these a bit tighter by not having the IK_FirstXXXInit
233 /// and IK_LastXXXInit be their own values, but that would degrade
234 /// readability for really no benefit.
251 IK_VarListElementInit,
259 Init(const Init &) = delete;
260 Init &operator=(const Init &) = delete;
261 virtual void anchor();
264 InitKind getKind() const { return Kind; }
267 explicit Init(InitKind K) : Kind(K) {}
272 /// isComplete - This virtual method should be overridden by values that may
273 /// not be completely specified yet.
274 virtual bool isComplete() const { return true; }
276 /// print - Print out this value.
277 void print(raw_ostream &OS) const { OS << getAsString(); }
279 /// getAsString - Convert this value to a string form.
280 virtual std::string getAsString() const = 0;
281 /// getAsUnquotedString - Convert this value to a string form,
282 /// without adding quote markers. This primaruly affects
283 /// StringInits where we will not surround the string value with
285 virtual std::string getAsUnquotedString() const { return getAsString(); }
287 /// dump - Debugging method that may be called through a debugger, just
288 /// invokes print on stderr.
291 /// convertInitializerTo - This virtual function converts to the appropriate
292 /// Init based on the passed in type.
293 virtual Init *convertInitializerTo(RecTy *Ty) const = 0;
295 /// convertInitializerBitRange - This method is used to implement the bitrange
296 /// selection operator. Given an initializer, it selects the specified bits
297 /// out, returning them as a new init of bits type. If it is not legal to use
298 /// the bit subscript operator on this initializer, return null.
301 convertInitializerBitRange(const std::vector<unsigned> &Bits) const {
305 /// convertInitListSlice - This method is used to implement the list slice
306 /// selection operator. Given an initializer, it selects the specified list
307 /// elements, returning them as a new init of list type. If it is not legal
308 /// to take a slice of this, return null.
311 convertInitListSlice(const std::vector<unsigned> &Elements) const {
315 /// getFieldType - This method is used to implement the FieldInit class.
316 /// Implementors of this method should return the type of the named field if
317 /// they are of record type.
319 virtual RecTy *getFieldType(const std::string &FieldName) const {
323 /// getFieldInit - This method complements getFieldType to return the
324 /// initializer for the specified field. If getFieldType returns non-null
325 /// this method should return non-null, otherwise it returns null.
327 virtual Init *getFieldInit(Record &R, const RecordVal *RV,
328 const std::string &FieldName) const {
332 /// resolveReferences - This method is used by classes that refer to other
333 /// variables which may not be defined at the time the expression is formed.
334 /// If a value is set for the variable later, this method will be called on
335 /// users of the value to allow the value to propagate out.
337 virtual Init *resolveReferences(Record &R, const RecordVal *RV) const {
338 return const_cast<Init *>(this);
341 /// getBit - This method is used to return the initializer for the specified
343 virtual Init *getBit(unsigned Bit) const = 0;
345 /// getBitVar - This method is used to retrieve the initializer for bit
346 /// reference. For non-VarBitInit, it simply returns itself.
347 virtual Init *getBitVar() const { return const_cast<Init*>(this); }
349 /// getBitNum - This method is used to retrieve the bit number of a bit
350 /// reference. For non-VarBitInit, it simply returns 0.
351 virtual unsigned getBitNum() const { return 0; }
354 inline raw_ostream &operator<<(raw_ostream &OS, const Init &I) {
355 I.print(OS); return OS;
358 /// TypedInit - This is the common super-class of types that have a specific,
361 class TypedInit : public Init {
364 TypedInit(const TypedInit &Other) = delete;
365 TypedInit &operator=(const TypedInit &Other) = delete;
368 explicit TypedInit(InitKind K, RecTy *T) : Init(K), Ty(T) {}
370 // If this is a DefInit we need to delete the RecordRecTy.
371 if (getKind() == IK_DefInit)
376 static bool classof(const Init *I) {
377 return I->getKind() >= IK_FirstTypedInit &&
378 I->getKind() <= IK_LastTypedInit;
380 RecTy *getType() const { return Ty; }
382 Init *convertInitializerTo(RecTy *Ty) const override;
385 convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
387 convertInitListSlice(const std::vector<unsigned> &Elements) const override;
389 /// getFieldType - This method is used to implement the FieldInit class.
390 /// Implementors of this method should return the type of the named field if
391 /// they are of record type.
393 RecTy *getFieldType(const std::string &FieldName) const override;
395 /// resolveListElementReference - This method is used to implement
396 /// VarListElementInit::resolveReferences. If the list element is resolvable
397 /// now, we return the resolved value, otherwise we return null.
398 virtual Init *resolveListElementReference(Record &R, const RecordVal *RV,
399 unsigned Elt) const = 0;
402 /// UnsetInit - ? - Represents an uninitialized value
404 class UnsetInit : public Init {
405 UnsetInit() : Init(IK_UnsetInit) {}
406 UnsetInit(const UnsetInit &) = delete;
407 UnsetInit &operator=(const UnsetInit &Other) = delete;
410 static bool classof(const Init *I) {
411 return I->getKind() == IK_UnsetInit;
413 static UnsetInit *get();
415 Init *convertInitializerTo(RecTy *Ty) const override;
417 Init *getBit(unsigned Bit) const override {
418 return const_cast<UnsetInit*>(this);
421 bool isComplete() const override { return false; }
422 std::string getAsString() const override { return "?"; }
425 /// BitInit - true/false - Represent a concrete initializer for a bit.
427 class BitInit : public Init {
430 explicit BitInit(bool V) : Init(IK_BitInit), Value(V) {}
431 BitInit(const BitInit &Other) = delete;
432 BitInit &operator=(BitInit &Other) = delete;
435 static bool classof(const Init *I) {
436 return I->getKind() == IK_BitInit;
438 static BitInit *get(bool V);
440 bool getValue() const { return Value; }
442 Init *convertInitializerTo(RecTy *Ty) const override;
444 Init *getBit(unsigned Bit) const override {
445 assert(Bit < 1 && "Bit index out of range!");
446 return const_cast<BitInit*>(this);
449 std::string getAsString() const override { return Value ? "1" : "0"; }
452 /// BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
453 /// It contains a vector of bits, whose size is determined by the type.
455 class BitsInit : public TypedInit, public FoldingSetNode {
456 std::vector<Init*> Bits;
458 BitsInit(ArrayRef<Init *> Range)
459 : TypedInit(IK_BitsInit, BitsRecTy::get(Range.size())),
460 Bits(Range.begin(), Range.end()) {}
462 BitsInit(const BitsInit &Other) = delete;
463 BitsInit &operator=(const BitsInit &Other) = delete;
466 static bool classof(const Init *I) {
467 return I->getKind() == IK_BitsInit;
469 static BitsInit *get(ArrayRef<Init *> Range);
471 void Profile(FoldingSetNodeID &ID) const;
473 unsigned getNumBits() const { return Bits.size(); }
475 Init *convertInitializerTo(RecTy *Ty) const override;
477 convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
479 bool isComplete() const override {
480 for (unsigned i = 0; i != getNumBits(); ++i)
481 if (!getBit(i)->isComplete()) return false;
484 bool allInComplete() const {
485 for (unsigned i = 0; i != getNumBits(); ++i)
486 if (getBit(i)->isComplete()) return false;
489 std::string getAsString() const override;
491 /// resolveListElementReference - This method is used to implement
492 /// VarListElementInit::resolveReferences. If the list element is resolvable
493 /// now, we return the resolved value, otherwise we return null.
494 Init *resolveListElementReference(Record &R, const RecordVal *RV,
495 unsigned Elt) const override {
496 llvm_unreachable("Illegal element reference off bits<n>");
499 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
501 Init *getBit(unsigned Bit) const override {
502 assert(Bit < Bits.size() && "Bit index out of range!");
507 /// IntInit - 7 - Represent an initialization by a literal integer value.
509 class IntInit : public TypedInit {
512 explicit IntInit(int64_t V)
513 : TypedInit(IK_IntInit, IntRecTy::get()), Value(V) {}
515 IntInit(const IntInit &Other) = delete;
516 IntInit &operator=(const IntInit &Other) = delete;
519 static bool classof(const Init *I) {
520 return I->getKind() == IK_IntInit;
522 static IntInit *get(int64_t V);
524 int64_t getValue() const { return Value; }
526 Init *convertInitializerTo(RecTy *Ty) const override;
528 convertInitializerBitRange(const std::vector<unsigned> &Bits) const override;
530 std::string getAsString() const override;
532 /// resolveListElementReference - This method is used to implement
533 /// VarListElementInit::resolveReferences. If the list element is resolvable
534 /// now, we return the resolved value, otherwise we return null.
535 Init *resolveListElementReference(Record &R, const RecordVal *RV,
536 unsigned Elt) const override {
537 llvm_unreachable("Illegal element reference off int");
540 Init *getBit(unsigned Bit) const override {
541 return BitInit::get((Value & (1ULL << Bit)) != 0);
545 /// StringInit - "foo" - Represent an initialization by a string value.
547 class StringInit : public TypedInit {
550 explicit StringInit(const std::string &V)
551 : TypedInit(IK_StringInit, StringRecTy::get()), Value(V) {}
553 StringInit(const StringInit &Other) = delete;
554 StringInit &operator=(const StringInit &Other) = delete;
557 static bool classof(const Init *I) {
558 return I->getKind() == IK_StringInit;
560 static StringInit *get(StringRef);
562 const std::string &getValue() const { return Value; }
564 Init *convertInitializerTo(RecTy *Ty) const override;
566 std::string getAsString() const override { return "\"" + Value + "\""; }
567 std::string getAsUnquotedString() const override { return Value; }
569 /// resolveListElementReference - This method is used to implement
570 /// VarListElementInit::resolveReferences. If the list element is resolvable
571 /// now, we return the resolved value, otherwise we return null.
572 Init *resolveListElementReference(Record &R, const RecordVal *RV,
573 unsigned Elt) const override {
574 llvm_unreachable("Illegal element reference off string");
577 Init *getBit(unsigned Bit) const override {
578 llvm_unreachable("Illegal bit reference off string");
582 /// ListInit - [AL, AH, CL] - Represent a list of defs
584 class ListInit : public TypedInit, public FoldingSetNode {
585 std::vector<Init*> Values;
588 typedef std::vector<Init*>::const_iterator const_iterator;
591 explicit ListInit(ArrayRef<Init *> Range, RecTy *EltTy)
592 : TypedInit(IK_ListInit, ListRecTy::get(EltTy)),
593 Values(Range.begin(), Range.end()) {}
595 ListInit(const ListInit &Other) = delete;
596 ListInit &operator=(const ListInit &Other) = delete;
599 static bool classof(const Init *I) {
600 return I->getKind() == IK_ListInit;
602 static ListInit *get(ArrayRef<Init *> Range, RecTy *EltTy);
604 void Profile(FoldingSetNodeID &ID) const;
606 Init *getElement(unsigned i) const {
607 assert(i < Values.size() && "List element index out of range!");
611 Record *getElementAsRecord(unsigned i) const;
614 convertInitListSlice(const std::vector<unsigned> &Elements) const override;
616 Init *convertInitializerTo(RecTy *Ty) const override;
618 /// resolveReferences - This method is used by classes that refer to other
619 /// variables which may not be defined at the time they expression is formed.
620 /// If a value is set for the variable later, this method will be called on
621 /// users of the value to allow the value to propagate out.
623 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
625 std::string getAsString() const override;
627 ArrayRef<Init*> getValues() const { return Values; }
629 const_iterator begin() const { return Values.begin(); }
630 const_iterator end () const { return Values.end(); }
632 size_t size () const { return Values.size(); }
633 bool empty() const { return Values.empty(); }
635 /// resolveListElementReference - This method is used to implement
636 /// VarListElementInit::resolveReferences. If the list element is resolvable
637 /// now, we return the resolved value, otherwise we return null.
638 Init *resolveListElementReference(Record &R, const RecordVal *RV,
639 unsigned Elt) const override;
641 Init *getBit(unsigned Bit) const override {
642 llvm_unreachable("Illegal bit reference off list");
646 /// OpInit - Base class for operators
648 class OpInit : public TypedInit {
649 OpInit(const OpInit &Other) = delete;
650 OpInit &operator=(OpInit &Other) = delete;
653 explicit OpInit(InitKind K, RecTy *Type) : TypedInit(K, Type) {}
656 static bool classof(const Init *I) {
657 return I->getKind() >= IK_FirstOpInit &&
658 I->getKind() <= IK_LastOpInit;
660 // Clone - Clone this operator, replacing arguments with the new list
661 virtual OpInit *clone(std::vector<Init *> &Operands) const = 0;
663 virtual int getNumOperands() const = 0;
664 virtual Init *getOperand(int i) const = 0;
666 // Fold - If possible, fold this to a simpler init. Return this if not
668 virtual Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const = 0;
670 Init *resolveListElementReference(Record &R, const RecordVal *RV,
671 unsigned Elt) const override;
673 Init *getBit(unsigned Bit) const override;
676 /// UnOpInit - !op (X) - Transform an init.
678 class UnOpInit : public OpInit {
680 enum UnaryOp { CAST, HEAD, TAIL, EMPTY };
686 UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type)
687 : OpInit(IK_UnOpInit, Type), Opc(opc), LHS(lhs) {}
689 UnOpInit(const UnOpInit &Other) = delete;
690 UnOpInit &operator=(const UnOpInit &Other) = delete;
693 static bool classof(const Init *I) {
694 return I->getKind() == IK_UnOpInit;
696 static UnOpInit *get(UnaryOp opc, Init *lhs, RecTy *Type);
698 // Clone - Clone this operator, replacing arguments with the new list
699 OpInit *clone(std::vector<Init *> &Operands) const override {
700 assert(Operands.size() == 1 &&
701 "Wrong number of operands for unary operation");
702 return UnOpInit::get(getOpcode(), *Operands.begin(), getType());
705 int getNumOperands() const override { return 1; }
706 Init *getOperand(int i) const override {
707 assert(i == 0 && "Invalid operand id for unary operator");
711 UnaryOp getOpcode() const { return Opc; }
712 Init *getOperand() const { return LHS; }
714 // Fold - If possible, fold this to a simpler init. Return this if not
716 Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
718 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
720 std::string getAsString() const override;
723 /// BinOpInit - !op (X, Y) - Combine two inits.
725 class BinOpInit : public OpInit {
727 enum BinaryOp { ADD, AND, SHL, SRA, SRL, LISTCONCAT, STRCONCAT, CONCAT, EQ };
733 BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) :
734 OpInit(IK_BinOpInit, Type), Opc(opc), LHS(lhs), RHS(rhs) {}
736 BinOpInit(const BinOpInit &Other) = delete;
737 BinOpInit &operator=(const BinOpInit &Other) = delete;
740 static bool classof(const Init *I) {
741 return I->getKind() == IK_BinOpInit;
743 static BinOpInit *get(BinaryOp opc, Init *lhs, Init *rhs,
746 // Clone - Clone this operator, replacing arguments with the new list
747 OpInit *clone(std::vector<Init *> &Operands) const override {
748 assert(Operands.size() == 2 &&
749 "Wrong number of operands for binary operation");
750 return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType());
753 int getNumOperands() const override { return 2; }
754 Init *getOperand(int i) const override {
755 assert((i == 0 || i == 1) && "Invalid operand id for binary operator");
763 BinaryOp getOpcode() const { return Opc; }
764 Init *getLHS() const { return LHS; }
765 Init *getRHS() const { return RHS; }
767 // Fold - If possible, fold this to a simpler init. Return this if not
769 Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
771 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
773 std::string getAsString() const override;
776 /// TernOpInit - !op (X, Y, Z) - Combine two inits.
778 class TernOpInit : public OpInit {
780 enum TernaryOp { SUBST, FOREACH, IF };
784 Init *LHS, *MHS, *RHS;
786 TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs,
788 OpInit(IK_TernOpInit, Type), Opc(opc), LHS(lhs), MHS(mhs), RHS(rhs) {}
790 TernOpInit(const TernOpInit &Other) = delete;
791 TernOpInit &operator=(const TernOpInit &Other) = delete;
794 static bool classof(const Init *I) {
795 return I->getKind() == IK_TernOpInit;
797 static TernOpInit *get(TernaryOp opc, Init *lhs,
798 Init *mhs, Init *rhs,
801 // Clone - Clone this operator, replacing arguments with the new list
802 OpInit *clone(std::vector<Init *> &Operands) const override {
803 assert(Operands.size() == 3 &&
804 "Wrong number of operands for ternary operation");
805 return TernOpInit::get(getOpcode(), Operands[0], Operands[1], Operands[2],
809 int getNumOperands() const override { return 3; }
810 Init *getOperand(int i) const override {
811 assert((i == 0 || i == 1 || i == 2) &&
812 "Invalid operand id for ternary operator");
822 TernaryOp getOpcode() const { return Opc; }
823 Init *getLHS() const { return LHS; }
824 Init *getMHS() const { return MHS; }
825 Init *getRHS() const { return RHS; }
827 // Fold - If possible, fold this to a simpler init. Return this if not
829 Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const override;
831 bool isComplete() const override { return false; }
833 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
835 std::string getAsString() const override;
838 /// VarInit - 'Opcode' - Represent a reference to an entire variable object.
840 class VarInit : public TypedInit {
843 explicit VarInit(const std::string &VN, RecTy *T)
844 : TypedInit(IK_VarInit, T), VarName(StringInit::get(VN)) {}
845 explicit VarInit(Init *VN, RecTy *T)
846 : TypedInit(IK_VarInit, T), VarName(VN) {}
848 VarInit(const VarInit &Other) = delete;
849 VarInit &operator=(const VarInit &Other) = delete;
852 static bool classof(const Init *I) {
853 return I->getKind() == IK_VarInit;
855 static VarInit *get(const std::string &VN, RecTy *T);
856 static VarInit *get(Init *VN, RecTy *T);
858 const std::string &getName() const;
859 Init *getNameInit() const { return VarName; }
860 std::string getNameInitAsString() const {
861 return getNameInit()->getAsUnquotedString();
864 Init *resolveListElementReference(Record &R, const RecordVal *RV,
865 unsigned Elt) const override;
867 RecTy *getFieldType(const std::string &FieldName) const override;
868 Init *getFieldInit(Record &R, const RecordVal *RV,
869 const std::string &FieldName) const override;
871 /// resolveReferences - This method is used by classes that refer to other
872 /// variables which may not be defined at the time they expression is formed.
873 /// If a value is set for the variable later, this method will be called on
874 /// users of the value to allow the value to propagate out.
876 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
878 Init *getBit(unsigned Bit) const override;
880 std::string getAsString() const override { return getName(); }
883 /// VarBitInit - Opcode{0} - Represent access to one bit of a variable or field.
885 class VarBitInit : public Init {
889 VarBitInit(TypedInit *T, unsigned B) : Init(IK_VarBitInit), TI(T), Bit(B) {
890 assert(T->getType() &&
891 (isa<IntRecTy>(T->getType()) ||
892 (isa<BitsRecTy>(T->getType()) &&
893 cast<BitsRecTy>(T->getType())->getNumBits() > B)) &&
894 "Illegal VarBitInit expression!");
897 VarBitInit(const VarBitInit &Other) = delete;
898 VarBitInit &operator=(const VarBitInit &Other) = delete;
901 static bool classof(const Init *I) {
902 return I->getKind() == IK_VarBitInit;
904 static VarBitInit *get(TypedInit *T, unsigned B);
906 Init *convertInitializerTo(RecTy *Ty) const override;
908 Init *getBitVar() const override { return TI; }
909 unsigned getBitNum() const override { return Bit; }
911 std::string getAsString() const override;
912 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
914 Init *getBit(unsigned B) const override {
915 assert(B < 1 && "Bit index out of range!");
916 return const_cast<VarBitInit*>(this);
920 /// VarListElementInit - List[4] - Represent access to one element of a var or
922 class VarListElementInit : public TypedInit {
926 VarListElementInit(TypedInit *T, unsigned E)
927 : TypedInit(IK_VarListElementInit,
928 cast<ListRecTy>(T->getType())->getElementType()),
930 assert(T->getType() && isa<ListRecTy>(T->getType()) &&
931 "Illegal VarBitInit expression!");
934 VarListElementInit(const VarListElementInit &Other) = delete;
935 void operator=(const VarListElementInit &Other) = delete;
938 static bool classof(const Init *I) {
939 return I->getKind() == IK_VarListElementInit;
941 static VarListElementInit *get(TypedInit *T, unsigned E);
943 TypedInit *getVariable() const { return TI; }
944 unsigned getElementNum() const { return Element; }
946 /// resolveListElementReference - This method is used to implement
947 /// VarListElementInit::resolveReferences. If the list element is resolvable
948 /// now, we return the resolved value, otherwise we return null.
949 Init *resolveListElementReference(Record &R, const RecordVal *RV,
950 unsigned Elt) const override;
952 std::string getAsString() const override;
953 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
955 Init *getBit(unsigned Bit) const override;
958 /// DefInit - AL - Represent a reference to a 'def' in the description
960 class DefInit : public TypedInit {
963 DefInit(Record *D, RecordRecTy *T) : TypedInit(IK_DefInit, T), Def(D) {}
966 DefInit(const DefInit &Other) = delete;
967 DefInit &operator=(const DefInit &Other) = delete;
970 static bool classof(const Init *I) {
971 return I->getKind() == IK_DefInit;
973 static DefInit *get(Record*);
975 Init *convertInitializerTo(RecTy *Ty) const override;
977 Record *getDef() const { return Def; }
979 //virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
981 RecTy *getFieldType(const std::string &FieldName) const override;
982 Init *getFieldInit(Record &R, const RecordVal *RV,
983 const std::string &FieldName) const override;
985 std::string getAsString() const override;
987 Init *getBit(unsigned Bit) const override {
988 llvm_unreachable("Illegal bit reference off def");
991 /// resolveListElementReference - This method is used to implement
992 /// VarListElementInit::resolveReferences. If the list element is resolvable
993 /// now, we return the resolved value, otherwise we return null.
994 Init *resolveListElementReference(Record &R, const RecordVal *RV,
995 unsigned Elt) const override {
996 llvm_unreachable("Illegal element reference off def");
1000 /// FieldInit - X.Y - Represent a reference to a subfield of a variable
1002 class FieldInit : public TypedInit {
1003 Init *Rec; // Record we are referring to
1004 std::string FieldName; // Field we are accessing
1006 FieldInit(Init *R, const std::string &FN)
1007 : TypedInit(IK_FieldInit, R->getFieldType(FN)), Rec(R), FieldName(FN) {
1008 assert(getType() && "FieldInit with non-record type!");
1011 FieldInit(const FieldInit &Other) = delete;
1012 FieldInit &operator=(const FieldInit &Other) = delete;
1015 static bool classof(const Init *I) {
1016 return I->getKind() == IK_FieldInit;
1018 static FieldInit *get(Init *R, const std::string &FN);
1019 static FieldInit *get(Init *R, const Init *FN);
1021 Init *getBit(unsigned Bit) const override;
1023 Init *resolveListElementReference(Record &R, const RecordVal *RV,
1024 unsigned Elt) const override;
1026 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
1028 std::string getAsString() const override {
1029 return Rec->getAsString() + "." + FieldName;
1033 /// DagInit - (v a, b) - Represent a DAG tree value. DAG inits are required
1034 /// to have at least one value then a (possibly empty) list of arguments. Each
1035 /// argument can have a name associated with it.
1037 class DagInit : public TypedInit, public FoldingSetNode {
1039 std::string ValName;
1040 std::vector<Init*> Args;
1041 std::vector<std::string> ArgNames;
1043 DagInit(Init *V, const std::string &VN,
1044 ArrayRef<Init *> ArgRange,
1045 ArrayRef<std::string> NameRange)
1046 : TypedInit(IK_DagInit, DagRecTy::get()), Val(V), ValName(VN),
1047 Args(ArgRange.begin(), ArgRange.end()),
1048 ArgNames(NameRange.begin(), NameRange.end()) {}
1050 DagInit(const DagInit &Other) = delete;
1051 DagInit &operator=(const DagInit &Other) = delete;
1054 static bool classof(const Init *I) {
1055 return I->getKind() == IK_DagInit;
1057 static DagInit *get(Init *V, const std::string &VN,
1058 ArrayRef<Init *> ArgRange,
1059 ArrayRef<std::string> NameRange);
1060 static DagInit *get(Init *V, const std::string &VN,
1062 std::pair<Init*, std::string> > &args);
1064 void Profile(FoldingSetNodeID &ID) const;
1066 Init *convertInitializerTo(RecTy *Ty) const override;
1068 Init *getOperator() const { return Val; }
1070 const std::string &getName() const { return ValName; }
1072 unsigned getNumArgs() const { return Args.size(); }
1073 Init *getArg(unsigned Num) const {
1074 assert(Num < Args.size() && "Arg number out of range!");
1077 const std::string &getArgName(unsigned Num) const {
1078 assert(Num < ArgNames.size() && "Arg number out of range!");
1079 return ArgNames[Num];
1082 Init *resolveReferences(Record &R, const RecordVal *RV) const override;
1084 std::string getAsString() const override;
1086 typedef std::vector<Init*>::const_iterator const_arg_iterator;
1087 typedef std::vector<std::string>::const_iterator const_name_iterator;
1089 inline const_arg_iterator arg_begin() const { return Args.begin(); }
1090 inline const_arg_iterator arg_end () const { return Args.end(); }
1092 inline size_t arg_size () const { return Args.size(); }
1093 inline bool arg_empty() const { return Args.empty(); }
1095 inline const_name_iterator name_begin() const { return ArgNames.begin(); }
1096 inline const_name_iterator name_end () const { return ArgNames.end(); }
1098 inline size_t name_size () const { return ArgNames.size(); }
1099 inline bool name_empty() const { return ArgNames.empty(); }
1101 Init *getBit(unsigned Bit) const override {
1102 llvm_unreachable("Illegal bit reference off dag");
1105 Init *resolveListElementReference(Record &R, const RecordVal *RV,
1106 unsigned Elt) const override {
1107 llvm_unreachable("Illegal element reference off dag");
1111 //===----------------------------------------------------------------------===//
1112 // High-Level Classes
1113 //===----------------------------------------------------------------------===//
1122 RecordVal(Init *N, RecTy *T, unsigned P);
1123 RecordVal(const std::string &N, RecTy *T, unsigned P);
1125 const std::string &getName() const;
1126 const Init *getNameInit() const { return Name; }
1127 std::string getNameInitAsString() const {
1128 return getNameInit()->getAsUnquotedString();
1131 unsigned getPrefix() const { return Prefix; }
1132 RecTy *getType() const { return Ty; }
1133 Init *getValue() const { return Value; }
1135 bool setValue(Init *V) {
1137 Value = V->convertInitializerTo(Ty);
1138 return Value == nullptr;
1145 void print(raw_ostream &OS, bool PrintSem = true) const;
1148 inline raw_ostream &operator<<(raw_ostream &OS, const RecordVal &RV) {
1149 RV.print(OS << " ");
1154 static unsigned LastID;
1156 // Unique record ID.
1159 // Location where record was instantiated, followed by the location of
1160 // multiclass prototypes used.
1161 SmallVector<SMLoc, 4> Locs;
1162 std::vector<Init *> TemplateArgs;
1163 std::vector<RecordVal> Values;
1164 std::vector<Record *> SuperClasses;
1165 std::vector<SMRange> SuperClassRanges;
1167 // Tracks Record instances. Not owned by Record.
1168 RecordKeeper &TrackedRecords;
1173 // Class-instance values can be used by other defs. For example, Struct<i>
1174 // is used here as a template argument to another class:
1176 // multiclass MultiClass<int i> {
1177 // def Def : Class<Struct<i>>;
1179 // These need to get fully resolved before instantiating any other
1180 // definitions that usie them (e.g. Def). However, inside a multiclass they
1181 // can't be immediately resolved so we mark them ResolveFirst to fully
1182 // resolve them later as soon as the multiclass is instantiated.
1189 // Constructs a record.
1190 explicit Record(const std::string &N, ArrayRef<SMLoc> locs,
1191 RecordKeeper &records, bool Anonymous = false) :
1192 ID(LastID++), Name(StringInit::get(N)), Locs(locs.begin(), locs.end()),
1193 TrackedRecords(records), TheInit(nullptr), IsAnonymous(Anonymous),
1194 ResolveFirst(false) {
1197 explicit Record(Init *N, ArrayRef<SMLoc> locs, RecordKeeper &records,
1198 bool Anonymous = false) :
1199 ID(LastID++), Name(N), Locs(locs.begin(), locs.end()),
1200 TrackedRecords(records), TheInit(nullptr), IsAnonymous(Anonymous),
1201 ResolveFirst(false) {
1205 // When copy-constructing a Record, we must still guarantee a globally unique
1206 // ID number. All other fields can be copied normally.
1207 Record(const Record &O) :
1208 ID(LastID++), Name(O.Name), Locs(O.Locs), TemplateArgs(O.TemplateArgs),
1209 Values(O.Values), SuperClasses(O.SuperClasses),
1210 SuperClassRanges(O.SuperClassRanges), TrackedRecords(O.TrackedRecords),
1211 TheInit(O.TheInit), IsAnonymous(O.IsAnonymous),
1212 ResolveFirst(O.ResolveFirst) { }
1214 static unsigned getNewUID() { return LastID++; }
1216 unsigned getID() const { return ID; }
1218 const std::string &getName() const;
1219 Init *getNameInit() const {
1222 const std::string getNameInitAsString() const {
1223 return getNameInit()->getAsUnquotedString();
1226 void setName(Init *Name); // Also updates RecordKeeper.
1227 void setName(const std::string &Name); // Also updates RecordKeeper.
1229 ArrayRef<SMLoc> getLoc() const { return Locs; }
1231 /// get the corresponding DefInit.
1232 DefInit *getDefInit();
1234 const std::vector<Init *> &getTemplateArgs() const {
1235 return TemplateArgs;
1237 const std::vector<RecordVal> &getValues() const { return Values; }
1238 const std::vector<Record*> &getSuperClasses() const { return SuperClasses; }
1239 ArrayRef<SMRange> getSuperClassRanges() const { return SuperClassRanges; }
1241 bool isTemplateArg(Init *Name) const {
1242 for (unsigned i = 0, e = TemplateArgs.size(); i != e; ++i)
1243 if (TemplateArgs[i] == Name) return true;
1246 bool isTemplateArg(StringRef Name) const {
1247 return isTemplateArg(StringInit::get(Name));
1250 const RecordVal *getValue(const Init *Name) const {
1251 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1252 if (Values[i].getNameInit() == Name) return &Values[i];
1255 const RecordVal *getValue(StringRef Name) const {
1256 return getValue(StringInit::get(Name));
1258 RecordVal *getValue(const Init *Name) {
1259 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1260 if (Values[i].getNameInit() == Name) return &Values[i];
1263 RecordVal *getValue(StringRef Name) {
1264 return getValue(StringInit::get(Name));
1267 void addTemplateArg(Init *Name) {
1268 assert(!isTemplateArg(Name) && "Template arg already defined!");
1269 TemplateArgs.push_back(Name);
1271 void addTemplateArg(StringRef Name) {
1272 addTemplateArg(StringInit::get(Name));
1275 void addValue(const RecordVal &RV) {
1276 assert(getValue(RV.getNameInit()) == nullptr && "Value already added!");
1277 Values.push_back(RV);
1278 if (Values.size() > 1)
1279 // Keep NAME at the end of the list. It makes record dumps a
1280 // bit prettier and allows TableGen tests to be written more
1281 // naturally. Tests can use CHECK-NEXT to look for Record
1282 // fields they expect to see after a def. They can't do that if
1283 // NAME is the first Record field.
1284 std::swap(Values[Values.size() - 2], Values[Values.size() - 1]);
1287 void removeValue(Init *Name) {
1288 for (unsigned i = 0, e = Values.size(); i != e; ++i)
1289 if (Values[i].getNameInit() == Name) {
1290 Values.erase(Values.begin()+i);
1293 llvm_unreachable("Cannot remove an entry that does not exist!");
1296 void removeValue(StringRef Name) {
1297 removeValue(StringInit::get(Name));
1300 bool isSubClassOf(const Record *R) const {
1301 for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
1302 if (SuperClasses[i] == R)
1307 bool isSubClassOf(StringRef Name) const {
1308 for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
1309 if (SuperClasses[i]->getNameInitAsString() == Name)
1314 void addSuperClass(Record *R, SMRange Range) {
1315 assert(!isSubClassOf(R) && "Already subclassing record!");
1316 SuperClasses.push_back(R);
1317 SuperClassRanges.push_back(Range);
1320 /// resolveReferences - If there are any field references that refer to fields
1321 /// that have been filled in, we can propagate the values now.
1323 void resolveReferences() { resolveReferencesTo(nullptr); }
1325 /// resolveReferencesTo - If anything in this record refers to RV, replace the
1326 /// reference to RV with the RHS of RV. If RV is null, we resolve all
1327 /// possible references.
1328 void resolveReferencesTo(const RecordVal *RV);
1330 RecordKeeper &getRecords() const {
1331 return TrackedRecords;
1334 bool isAnonymous() const {
1338 bool isResolveFirst() const {
1339 return ResolveFirst;
1342 void setResolveFirst(bool b) {
1348 //===--------------------------------------------------------------------===//
1349 // High-level methods useful to tablegen back-ends
1352 /// getValueInit - Return the initializer for a value with the specified name,
1353 /// or throw an exception if the field does not exist.
1355 Init *getValueInit(StringRef FieldName) const;
1357 /// Return true if the named field is unset.
1358 bool isValueUnset(StringRef FieldName) const {
1359 return getValueInit(FieldName) == UnsetInit::get();
1362 /// getValueAsString - This method looks up the specified field and returns
1363 /// its value as a string, throwing an exception if the field does not exist
1364 /// or if the value is not a string.
1366 std::string getValueAsString(StringRef FieldName) const;
1368 /// getValueAsBitsInit - This method looks up the specified field and returns
1369 /// its value as a BitsInit, throwing an exception if the field does not exist
1370 /// or if the value is not the right type.
1372 BitsInit *getValueAsBitsInit(StringRef FieldName) const;
1374 /// getValueAsListInit - This method looks up the specified field and returns
1375 /// its value as a ListInit, throwing an exception if the field does not exist
1376 /// or if the value is not the right type.
1378 ListInit *getValueAsListInit(StringRef FieldName) const;
1380 /// getValueAsListOfDefs - This method looks up the specified field and
1381 /// returns its value as a vector of records, throwing an exception if the
1382 /// field does not exist or if the value is not the right type.
1384 std::vector<Record*> getValueAsListOfDefs(StringRef FieldName) const;
1386 /// getValueAsListOfInts - This method looks up the specified field and
1387 /// returns its value as a vector of integers, throwing an exception if the
1388 /// field does not exist or if the value is not the right type.
1390 std::vector<int64_t> getValueAsListOfInts(StringRef FieldName) const;
1392 /// getValueAsListOfStrings - This method looks up the specified field and
1393 /// returns its value as a vector of strings, throwing an exception if the
1394 /// field does not exist or if the value is not the right type.
1396 std::vector<std::string> getValueAsListOfStrings(StringRef FieldName) const;
1398 /// getValueAsDef - This method looks up the specified field and returns its
1399 /// value as a Record, throwing an exception if the field does not exist or if
1400 /// the value is not the right type.
1402 Record *getValueAsDef(StringRef FieldName) const;
1404 /// getValueAsBit - This method looks up the specified field and returns its
1405 /// value as a bit, throwing an exception if the field does not exist or if
1406 /// the value is not the right type.
1408 bool getValueAsBit(StringRef FieldName) const;
1410 /// getValueAsBitOrUnset - This method looks up the specified field and
1411 /// returns its value as a bit. If the field is unset, sets Unset to true and
1414 bool getValueAsBitOrUnset(StringRef FieldName, bool &Unset) const;
1416 /// getValueAsInt - This method looks up the specified field and returns its
1417 /// value as an int64_t, throwing an exception if the field does not exist or
1418 /// if the value is not the right type.
1420 int64_t getValueAsInt(StringRef FieldName) const;
1422 /// getValueAsDag - This method looks up the specified field and returns its
1423 /// value as an Dag, throwing an exception if the field does not exist or if
1424 /// the value is not the right type.
1426 DagInit *getValueAsDag(StringRef FieldName) const;
1429 raw_ostream &operator<<(raw_ostream &OS, const Record &R);
1432 Record Rec; // Placeholder for template args and Name.
1433 typedef std::vector<std::unique_ptr<Record>> RecordVector;
1434 RecordVector DefPrototypes;
1438 MultiClass(const std::string &Name, SMLoc Loc, RecordKeeper &Records) :
1439 Rec(Name, Loc, Records) {}
1442 class RecordKeeper {
1443 typedef std::map<std::string, std::unique_ptr<Record>> RecordMap;
1444 RecordMap Classes, Defs;
1447 const RecordMap &getClasses() const { return Classes; }
1448 const RecordMap &getDefs() const { return Defs; }
1450 Record *getClass(const std::string &Name) const {
1451 auto I = Classes.find(Name);
1452 return I == Classes.end() ? nullptr : I->second.get();
1454 Record *getDef(const std::string &Name) const {
1455 auto I = Defs.find(Name);
1456 return I == Defs.end() ? nullptr : I->second.get();
1458 void addClass(std::unique_ptr<Record> R) {
1459 bool Ins = Classes.insert(std::make_pair(R->getName(),
1460 std::move(R))).second;
1462 assert(Ins && "Class already exists");
1464 void addDef(std::unique_ptr<Record> R) {
1465 bool Ins = Defs.insert(std::make_pair(R->getName(),
1466 std::move(R))).second;
1468 assert(Ins && "Record already exists");
1471 //===--------------------------------------------------------------------===//
1472 // High-level helper methods, useful for tablegen backends...
1474 /// getAllDerivedDefinitions - This method returns all concrete definitions
1475 /// that derive from the specified class name. If a class with the specified
1476 /// name does not exist, an exception is thrown.
1477 std::vector<Record*>
1478 getAllDerivedDefinitions(const std::string &ClassName) const;
1483 /// LessRecord - Sorting predicate to sort record pointers by name.
1486 bool operator()(const Record *Rec1, const Record *Rec2) const {
1487 return StringRef(Rec1->getName()).compare_numeric(Rec2->getName()) < 0;
1491 /// LessRecordByID - Sorting predicate to sort record pointers by their
1492 /// unique ID. If you just need a deterministic order, use this, since it
1493 /// just compares two `unsigned`; the other sorting predicates require
1494 /// string manipulation.
1495 struct LessRecordByID {
1496 bool operator()(const Record *LHS, const Record *RHS) const {
1497 return LHS->getID() < RHS->getID();
1501 /// LessRecordFieldName - Sorting predicate to sort record pointers by their
1504 struct LessRecordFieldName {
1505 bool operator()(const Record *Rec1, const Record *Rec2) const {
1506 return Rec1->getValueAsString("Name") < Rec2->getValueAsString("Name");
1510 struct LessRecordRegister {
1511 static size_t min(size_t a, size_t b) { return a < b ? a : b; }
1512 static bool ascii_isdigit(char x) { return x >= '0' && x <= '9'; }
1514 struct RecordParts {
1515 SmallVector<std::pair< bool, StringRef>, 4> Parts;
1517 RecordParts(StringRef Rec) {
1522 const char *Start = Rec.data();
1523 const char *Curr = Start;
1524 bool isDigitPart = ascii_isdigit(Curr[0]);
1525 for (size_t I = 0, E = Rec.size(); I != E; ++I, ++Len) {
1526 bool isDigit = ascii_isdigit(Curr[I]);
1527 if (isDigit != isDigitPart) {
1528 Parts.push_back(std::make_pair(isDigitPart, StringRef(Start, Len)));
1531 isDigitPart = ascii_isdigit(Curr[I]);
1534 // Push the last part.
1535 Parts.push_back(std::make_pair(isDigitPart, StringRef(Start, Len)));
1538 size_t size() { return Parts.size(); }
1540 std::pair<bool, StringRef> getPart(size_t i) {
1541 assert (i < Parts.size() && "Invalid idx!");
1546 bool operator()(const Record *Rec1, const Record *Rec2) const {
1547 RecordParts LHSParts(StringRef(Rec1->getName()));
1548 RecordParts RHSParts(StringRef(Rec2->getName()));
1550 size_t LHSNumParts = LHSParts.size();
1551 size_t RHSNumParts = RHSParts.size();
1552 assert (LHSNumParts && RHSNumParts && "Expected at least one part!");
1554 if (LHSNumParts != RHSNumParts)
1555 return LHSNumParts < RHSNumParts;
1557 // We expect the registers to be of the form [_a-zA-z]+([0-9]*[_a-zA-Z]*)*.
1558 for (size_t I = 0, E = LHSNumParts; I < E; I+=2) {
1559 std::pair<bool, StringRef> LHSPart = LHSParts.getPart(I);
1560 std::pair<bool, StringRef> RHSPart = RHSParts.getPart(I);
1561 // Expect even part to always be alpha.
1562 assert (LHSPart.first == false && RHSPart.first == false &&
1563 "Expected both parts to be alpha.");
1564 if (int Res = LHSPart.second.compare(RHSPart.second))
1567 for (size_t I = 1, E = LHSNumParts; I < E; I+=2) {
1568 std::pair<bool, StringRef> LHSPart = LHSParts.getPart(I);
1569 std::pair<bool, StringRef> RHSPart = RHSParts.getPart(I);
1570 // Expect odd part to always be numeric.
1571 assert (LHSPart.first == true && RHSPart.first == true &&
1572 "Expected both parts to be numeric.");
1573 if (LHSPart.second.size() != RHSPart.second.size())
1574 return LHSPart.second.size() < RHSPart.second.size();
1576 unsigned LHSVal, RHSVal;
1578 bool LHSFailed = LHSPart.second.getAsInteger(10, LHSVal); (void)LHSFailed;
1579 assert(!LHSFailed && "Unable to convert LHS to integer.");
1580 bool RHSFailed = RHSPart.second.getAsInteger(10, RHSVal); (void)RHSFailed;
1581 assert(!RHSFailed && "Unable to convert RHS to integer.");
1583 if (LHSVal != RHSVal)
1584 return LHSVal < RHSVal;
1586 return LHSNumParts < RHSNumParts;
1590 raw_ostream &operator<<(raw_ostream &OS, const RecordKeeper &RK);
1592 /// QualifyName - Return an Init with a qualifier prefix referring
1593 /// to CurRec's name.
1594 Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
1595 Init *Name, const std::string &Scoper);
1597 /// QualifyName - Return an Init with a qualifier prefix referring
1598 /// to CurRec's name.
1599 Init *QualifyName(Record &CurRec, MultiClass *CurMultiClass,
1600 const std::string &Name, const std::string &Scoper);
1602 } // End llvm namespace