1 //===- Record.h - Classes to represent Table Records ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source 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 //===----------------------------------------------------------------------===//
26 // RecTy subclasses...
55 //===----------------------------------------------------------------------===//
57 //===----------------------------------------------------------------------===//
62 virtual void print(std::ostream &OS) const = 0;
65 /// typeIsConvertibleTo - Return true if all values of 'this' type can be
66 /// converted to the specified type.
67 virtual bool typeIsConvertibleTo(const RecTy *RHS) const = 0;
69 public: // These methods should only be called from subclasses of Init
70 virtual Init *convertValue( UnsetInit *UI) { return 0; }
71 virtual Init *convertValue( BitInit *BI) { return 0; }
72 virtual Init *convertValue( BitsInit *BI) { return 0; }
73 virtual Init *convertValue( IntInit *II) { return 0; }
74 virtual Init *convertValue(StringInit *SI) { return 0; }
75 virtual Init *convertValue( ListInit *LI) { return 0; }
76 virtual Init *convertValue( CodeInit *CI) { return 0; }
77 virtual Init *convertValue(VarBitInit *VB) { return 0; }
78 virtual Init *convertValue( DefInit *DI) { return 0; }
79 virtual Init *convertValue( DagInit *DI) { return 0; }
80 virtual Init *convertValue( TypedInit *TI) { return 0; }
81 virtual Init *convertValue( VarInit *VI) {
82 return convertValue((TypedInit*)VI);
84 virtual Init *convertValue( FieldInit *FI) {
85 return convertValue((TypedInit*)FI);
88 public: // These methods should only be called by subclasses of RecTy.
89 // baseClassOf - These virtual methods should be overloaded to return true iff
90 // all values of type 'RHS' can be converted to the 'this' type.
91 virtual bool baseClassOf(const BitRecTy *RHS) const { return false; }
92 virtual bool baseClassOf(const BitsRecTy *RHS) const { return false; }
93 virtual bool baseClassOf(const IntRecTy *RHS) const { return false; }
94 virtual bool baseClassOf(const StringRecTy *RHS) const { return false; }
95 virtual bool baseClassOf(const ListRecTy *RHS) const { return false; }
96 virtual bool baseClassOf(const CodeRecTy *RHS) const { return false; }
97 virtual bool baseClassOf(const DagRecTy *RHS) const { return false; }
98 virtual bool baseClassOf(const RecordRecTy *RHS) const { return false; }
101 inline std::ostream &operator<<(std::ostream &OS, const RecTy &Ty) {
107 /// BitRecTy - 'bit' - Represent a single bit
109 struct BitRecTy : public RecTy {
110 Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
111 Init *convertValue(BitInit *BI) { return (Init*)BI; }
112 Init *convertValue(BitsInit *BI);
113 Init *convertValue(IntInit *II);
114 Init *convertValue(TypedInit *VI);
115 Init *convertValue(VarBitInit *VB) { return (Init*)VB; }
117 void print(std::ostream &OS) const { OS << "bit"; }
119 bool typeIsConvertibleTo(const RecTy *RHS) const {
120 return RHS->baseClassOf(this);
122 virtual bool baseClassOf(const BitRecTy *RHS) const { return true; }
123 virtual bool baseClassOf(const BitsRecTy *RHS) const;
124 virtual bool baseClassOf(const IntRecTy *RHS) const { return true; }
128 // BitsRecTy - 'bits<n>' - Represent a fixed number of bits
129 /// BitsRecTy - 'bits<n>' - Represent a fixed number of bits
131 class BitsRecTy : public RecTy {
134 BitsRecTy(unsigned Sz) : Size(Sz) {}
136 unsigned getNumBits() const { return Size; }
138 Init *convertValue(UnsetInit *UI);
139 Init *convertValue(BitInit *UI);
140 Init *convertValue(BitsInit *BI);
141 Init *convertValue(IntInit *II);
142 Init *convertValue(TypedInit *VI);
144 void print(std::ostream &OS) const { OS << "bits<" << Size << ">"; }
146 bool typeIsConvertibleTo(const RecTy *RHS) const {
147 return RHS->baseClassOf(this);
149 virtual bool baseClassOf(const BitRecTy *RHS) const { return Size == 1; }
150 virtual bool baseClassOf(const IntRecTy *RHS) const { return true; }
151 virtual bool baseClassOf(const BitsRecTy *RHS) const {
152 return RHS->Size == Size;
157 /// IntRecTy - 'int' - Represent an integer value of no particular size
159 struct IntRecTy : public RecTy {
160 Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
161 Init *convertValue(IntInit *II) { return (Init*)II; }
162 Init *convertValue(BitInit *BI);
163 Init *convertValue(BitsInit *BI);
164 Init *convertValue(TypedInit *TI);
166 void print(std::ostream &OS) const { OS << "int"; }
168 bool typeIsConvertibleTo(const RecTy *RHS) const {
169 return RHS->baseClassOf(this);
172 virtual bool baseClassOf(const BitRecTy *RHS) const { return true; }
173 virtual bool baseClassOf(const IntRecTy *RHS) const { return true; }
174 virtual bool baseClassOf(const BitsRecTy *RHS) const { return true; }
177 /// StringRecTy - 'string' - Represent an string value
179 struct StringRecTy : public RecTy {
180 Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
181 Init *convertValue(StringInit *SI) { return (Init*)SI; }
182 Init *convertValue(TypedInit *TI);
183 void print(std::ostream &OS) const { OS << "string"; }
185 bool typeIsConvertibleTo(const RecTy *RHS) const {
186 return RHS->baseClassOf(this);
189 virtual bool baseClassOf(const StringRecTy *RHS) const { return true; }
192 // ListRecTy - 'list<Ty>' - Represent a list of values, all of which must be of
193 // the specified type.
194 /// ListRecTy - 'list<Ty>' - Represent a list of values, all of which must
195 /// be of the specified type.
197 class ListRecTy : public RecTy {
200 ListRecTy(RecTy *T) : Ty(T) {}
202 RecTy *getElementType() const { return Ty; }
204 Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
205 Init *convertValue(ListInit *LI);
206 Init *convertValue(TypedInit *TI);
208 void print(std::ostream &OS) const;
210 bool typeIsConvertibleTo(const RecTy *RHS) const {
211 return RHS->baseClassOf(this);
214 virtual bool baseClassOf(const ListRecTy *RHS) const {
215 return RHS->getElementType()->typeIsConvertibleTo(Ty);
219 /// CodeRecTy - 'code' - Represent an code fragment, function or method.
221 struct CodeRecTy : public RecTy {
222 Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
223 Init *convertValue( CodeInit *CI) { return (Init*)CI; }
224 Init *convertValue(TypedInit *TI);
226 void print(std::ostream &OS) const { OS << "code"; }
228 bool typeIsConvertibleTo(const RecTy *RHS) const {
229 return RHS->baseClassOf(this);
231 virtual bool baseClassOf(const CodeRecTy *RHS) const { return true; }
234 /// DagRecTy - 'dag' - Represent a dag fragment
236 struct DagRecTy : public RecTy {
237 Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
238 Init *convertValue( DagInit *CI) { return (Init*)CI; }
239 Init *convertValue(TypedInit *TI);
241 void print(std::ostream &OS) const { OS << "dag"; }
243 bool typeIsConvertibleTo(const RecTy *RHS) const {
244 return RHS->baseClassOf(this);
246 virtual bool baseClassOf(const DagRecTy *RHS) const { return true; }
250 /// RecordRecTy - '[classname]' - Represent an instance of a class, such as:
253 class RecordRecTy : public RecTy {
256 RecordRecTy(Record *R) : Rec(R) {}
258 Record *getRecord() const { return Rec; }
260 Init *convertValue(UnsetInit *UI) { return (Init*)UI; }
261 Init *convertValue( DefInit *DI);
262 Init *convertValue(TypedInit *VI);
264 void print(std::ostream &OS) const;
266 bool typeIsConvertibleTo(const RecTy *RHS) const {
267 return RHS->baseClassOf(this);
269 virtual bool baseClassOf(const RecordRecTy *RHS) const;
274 //===----------------------------------------------------------------------===//
275 // Initializer Classes
276 //===----------------------------------------------------------------------===//
281 /// isComplete - This virtual method should be overridden by values that may
282 /// not be completely specified yet.
283 virtual bool isComplete() const { return true; }
285 /// print - Print out this value.
286 virtual void print(std::ostream &OS) const = 0;
288 /// dump - Debugging method that may be called through a debugger, just
289 /// invokes print on cerr.
292 /// convertInitializerTo - This virtual function is a simple call-back
293 /// function that should be overridden to call the appropriate
294 /// RecTy::convertValue method.
296 virtual Init *convertInitializerTo(RecTy *Ty) = 0;
298 /// convertInitializerBitRange - This method is used to implement the bitrange
299 /// selection operator. Given an initializer, it selects the specified bits
300 /// out, returning them as a new init of bits type. If it is not legal to use
301 /// the bit subscript operator on this initializer, return null.
303 virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits) {
307 /// getFieldType - This method is used to implement the FieldInit class.
308 /// Implementors of this method should return the type of the named field if
309 /// they are of record type.
311 virtual RecTy *getFieldType(const std::string &FieldName) const { return 0; }
313 /// getFieldInit - This method complements getFieldType to return the
314 /// initializer for the specified field. If getFieldType returns non-null
315 /// this method should return non-null, otherwise it returns null.
317 virtual Init *getFieldInit(Record &R, const std::string &FieldName) const {
321 /// resolveReferences - This method is used by classes that refer to other
322 /// variables which may not be defined at the time they expression is formed.
323 /// If a value is set for the variable later, this method will be called on
324 /// users of the value to allow the value to propagate out.
326 virtual Init *resolveReferences(Record &R) { return this; }
329 inline std::ostream &operator<<(std::ostream &OS, const Init &I) {
330 I.print(OS); return OS;
334 /// UnsetInit - ? - Represents an uninitialized value
336 struct UnsetInit : public Init {
337 virtual Init *convertInitializerTo(RecTy *Ty) {
338 return Ty->convertValue(this);
341 virtual bool isComplete() const { return false; }
342 virtual void print(std::ostream &OS) const { OS << "?"; }
346 /// BitInit - true/false - Represent a concrete initializer for a bit.
348 class BitInit : public Init {
351 BitInit(bool V) : Value(V) {}
353 bool getValue() const { return Value; }
355 virtual Init *convertInitializerTo(RecTy *Ty) {
356 return Ty->convertValue(this);
359 virtual void print(std::ostream &OS) const { OS << (Value ? "1" : "0"); }
362 /// BitsInit - { a, b, c } - Represents an initializer for a BitsRecTy value.
363 /// It contains a vector of bits, whose size is determined by the type.
365 class BitsInit : public Init {
366 std::vector<Init*> Bits;
368 BitsInit(unsigned Size) : Bits(Size) {}
370 unsigned getNumBits() const { return Bits.size(); }
372 Init *getBit(unsigned Bit) const {
373 assert(Bit < Bits.size() && "Bit index out of range!");
376 void setBit(unsigned Bit, Init *V) {
377 assert(Bit < Bits.size() && "Bit index out of range!");
378 assert(Bits[Bit] == 0 && "Bit already set!");
382 virtual Init *convertInitializerTo(RecTy *Ty) {
383 return Ty->convertValue(this);
385 virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
387 virtual bool isComplete() const {
388 for (unsigned i = 0; i != getNumBits(); ++i)
389 if (!getBit(i)->isComplete()) return false;
392 virtual void print(std::ostream &OS) const;
394 virtual Init *resolveReferences(Record &R);
396 // printXX - Print this bitstream with the specified format, returning true if
397 // it is not possible.
398 bool printInHex(std::ostream &OS) const;
399 bool printAsVariable(std::ostream &OS) const;
400 bool printAsUnset(std::ostream &OS) const;
404 /// IntInit - 7 - Represent an initalization by a literal integer value.
406 class IntInit : public Init {
409 IntInit(int V) : Value(V) {}
411 int getValue() const { return Value; }
413 virtual Init *convertInitializerTo(RecTy *Ty) {
414 return Ty->convertValue(this);
416 virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
418 virtual void print(std::ostream &OS) const { OS << Value; }
422 /// StringInit - "foo" - Represent an initialization by a string value.
424 class StringInit : public Init {
427 StringInit(const std::string &V) : Value(V) {}
429 const std::string &getValue() const { return Value; }
431 virtual Init *convertInitializerTo(RecTy *Ty) {
432 return Ty->convertValue(this);
435 virtual void print(std::ostream &OS) const { OS << "\"" << Value << "\""; }
438 /// CodeInit - "[{...}]" - Represent a code fragment.
440 class CodeInit : public Init {
443 CodeInit(const std::string &V) : Value(V) {}
445 const std::string getValue() const { return Value; }
447 virtual Init *convertInitializerTo(RecTy *Ty) {
448 return Ty->convertValue(this);
451 virtual void print(std::ostream &OS) const { OS << "[{" << Value << "}]"; }
454 /// ListInit - [AL, AH, CL] - Represent a list of defs
456 class ListInit : public Init {
457 std::vector<Init*> Values;
459 ListInit(std::vector<Init*> &Vs) {
463 unsigned getSize() const { return Values.size(); }
464 Init *getElement(unsigned i) const {
465 assert(i < Values.size() && "List element index out of range!");
469 virtual Init *convertInitializerTo(RecTy *Ty) {
470 return Ty->convertValue(this);
473 virtual void print(std::ostream &OS) const;
477 /// TypedInit - This is the common super-class of types that have a specific,
480 class TypedInit : public Init {
483 TypedInit(RecTy *T) : Ty(T) {}
485 RecTy *getType() const { return Ty; }
487 /// resolveBitReference - This method is used to implement
488 /// VarBitInit::resolveReferences. If the bit is able to be resolved, we
489 /// simply return the resolved value, otherwise we return this.
491 virtual Init *resolveBitReference(Record &R, unsigned Bit) = 0;
494 /// VarInit - 'Opcode' - Represent a reference to an entire variable object.
496 class VarInit : public TypedInit {
499 VarInit(const std::string &VN, RecTy *T) : TypedInit(T), VarName(VN) {}
501 virtual Init *convertInitializerTo(RecTy *Ty) {
502 return Ty->convertValue(this);
505 const std::string &getName() const { return VarName; }
507 virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
509 virtual Init *resolveBitReference(Record &R, unsigned Bit);
511 virtual RecTy *getFieldType(const std::string &FieldName) const;
512 virtual Init *getFieldInit(Record &R, const std::string &FieldName) const;
514 /// resolveReferences - This method is used by classes that refer to other
515 /// variables which may not be defined at the time they expression is formed.
516 /// If a value is set for the variable later, this method will be called on
517 /// users of the value to allow the value to propagate out.
519 virtual Init *resolveReferences(Record &R);
521 virtual void print(std::ostream &OS) const { OS << VarName; }
525 /// VarBitInit - Opcode{0} - Represent access to one bit of a variable or field.
527 class VarBitInit : public Init {
531 VarBitInit(TypedInit *T, unsigned B) : TI(T), Bit(B) {
532 assert(T->getType() && dynamic_cast<BitsRecTy*>(T->getType()) &&
533 ((BitsRecTy*)T->getType())->getNumBits() > B &&
534 "Illegal VarBitInit expression!");
537 virtual Init *convertInitializerTo(RecTy *Ty) {
538 return Ty->convertValue(this);
541 TypedInit *getVariable() const { return TI; }
542 unsigned getBitNum() const { return Bit; }
544 virtual void print(std::ostream &OS) const {
545 TI->print(OS); OS << "{" << Bit << "}";
547 virtual Init *resolveReferences(Record &R);
551 /// DefInit - AL - Represent a reference to a 'def' in the description
553 class DefInit : public Init {
556 DefInit(Record *D) : Def(D) {}
558 virtual Init *convertInitializerTo(RecTy *Ty) {
559 return Ty->convertValue(this);
562 Record *getDef() const { return Def; }
564 //virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
566 virtual RecTy *getFieldType(const std::string &FieldName) const;
567 virtual Init *getFieldInit(Record &R, const std::string &FieldName) const;
569 virtual void print(std::ostream &OS) const;
573 /// FieldInit - X.Y - Represent a reference to a subfield of a variable
575 class FieldInit : public TypedInit {
576 Init *Rec; // Record we are referring to
577 std::string FieldName; // Field we are accessing
579 FieldInit(Init *R, const std::string &FN)
580 : TypedInit(R->getFieldType(FN)), Rec(R), FieldName(FN) {
581 assert(getType() && "FieldInit with non-record type!");
584 virtual Init *convertInitializerTo(RecTy *Ty) {
585 return Ty->convertValue(this);
588 virtual Init *convertInitializerBitRange(const std::vector<unsigned> &Bits);
590 virtual Init *resolveBitReference(Record &R, unsigned Bit);
592 virtual Init *resolveReferences(Record &R);
594 virtual void print(std::ostream &OS) const {
595 Rec->print(OS); OS << "." << FieldName;
599 /// DagInit - (def a, b) - Represent a DAG tree value. DAG inits are required
600 /// to have Records for their first value, after that, any legal Init is
603 class DagInit : public Init {
605 std::vector<Init*> Args;
606 std::vector<std::string> ArgNames;
608 DagInit(Record *D, const std::vector<std::pair<Init*, std::string> > &args)
610 Args.reserve(args.size());
611 ArgNames.reserve(args.size());
612 for (unsigned i = 0, e = args.size(); i != e; ++i) {
613 Args.push_back(args[i].first);
614 ArgNames.push_back(args[i].second);
618 virtual Init *convertInitializerTo(RecTy *Ty) {
619 return Ty->convertValue(this);
622 Record *getNodeType() const { return NodeTypeDef; }
624 unsigned getNumArgs() const { return Args.size(); }
625 Init *getArg(unsigned Num) const {
626 assert(Num < Args.size() && "Arg number out of range!");
629 const std::string &getArgName(unsigned Num) const {
630 assert(Num < ArgNames.size() && "Arg number out of range!");
631 return ArgNames[Num];
634 void setArg(unsigned Num, Init *I) {
635 assert(Num < Args.size() && "Arg number out of range!");
639 virtual void print(std::ostream &OS) const;
642 //===----------------------------------------------------------------------===//
643 // High-Level Classes
644 //===----------------------------------------------------------------------===//
652 RecordVal(const std::string &N, RecTy *T, unsigned P);
654 const std::string &getName() const { return Name; }
656 unsigned getPrefix() const { return Prefix; }
657 RecTy *getType() const { return Ty; }
658 Init *getValue() const { return Value; }
660 bool setValue(Init *V) {
662 Value = V->convertInitializerTo(Ty);
670 void print(std::ostream &OS, bool PrintSem = true) const;
673 inline std::ostream &operator<<(std::ostream &OS, const RecordVal &RV) {
679 const std::string Name;
680 std::vector<std::string> TemplateArgs;
681 std::vector<RecordVal> Values;
682 std::vector<Record*> SuperClasses;
685 Record(const std::string &N) : Name(N) {}
688 const std::string &getName() const { return Name; }
689 const std::vector<std::string> &getTemplateArgs() const {
692 const std::vector<RecordVal> &getValues() const { return Values; }
693 const std::vector<Record*> &getSuperClasses() const { return SuperClasses; }
695 bool isTemplateArg(const std::string &Name) const {
696 for (unsigned i = 0, e = TemplateArgs.size(); i != e; ++i)
697 if (TemplateArgs[i] == Name) return true;
701 const RecordVal *getValue(const std::string &Name) const {
702 for (unsigned i = 0, e = Values.size(); i != e; ++i)
703 if (Values[i].getName() == Name) return &Values[i];
706 RecordVal *getValue(const std::string &Name) {
707 for (unsigned i = 0, e = Values.size(); i != e; ++i)
708 if (Values[i].getName() == Name) return &Values[i];
712 void addTemplateArg(const std::string &Name) {
713 assert(!isTemplateArg(Name) && "Template arg already defined!");
714 TemplateArgs.push_back(Name);
717 void addValue(const RecordVal &RV) {
718 assert(getValue(RV.getName()) == 0 && "Value already added!");
719 Values.push_back(RV);
722 void removeValue(const std::string &Name) {
723 assert(getValue(Name) && "Cannot remove an entry that does not exist!");
724 for (unsigned i = 0, e = Values.size(); i != e; ++i)
725 if (Values[i].getName() == Name) {
726 Values.erase(Values.begin()+i);
729 assert(0 && "Name does not exist in record!");
732 bool isSubClassOf(Record *R) const {
733 for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
734 if (SuperClasses[i] == R)
739 bool isSubClassOf(const std::string &Name) const {
740 for (unsigned i = 0, e = SuperClasses.size(); i != e; ++i)
741 if (SuperClasses[i]->getName() == Name)
746 void addSuperClass(Record *R) {
747 assert(!isSubClassOf(R) && "Already subclassing record!");
748 SuperClasses.push_back(R);
751 // resolveReferences - If there are any field references that refer to fields
752 // that have been filled in, we can propagate the values now.
754 void resolveReferences();
758 //===--------------------------------------------------------------------===//
759 // High-level methods useful to tablegen back-ends
762 /// getValueInit - Return the initializer for a value with the specified name,
763 /// or throw an exception if the field does not exist.
765 Init *getValueInit(const std::string &FieldName) const;
767 /// getValueAsString - This method looks up the specified field and returns
768 /// its value as a string, throwing an exception if the field does not exist
769 /// or if the value is not a string.
771 std::string getValueAsString(const std::string &FieldName) const;
773 /// getValueAsBitsInit - This method looks up the specified field and returns
774 /// its value as a BitsInit, throwing an exception if the field does not exist
775 /// or if the value is not the right type.
777 BitsInit *getValueAsBitsInit(const std::string &FieldName) const;
779 /// getValueAsListInit - This method looks up the specified field and returns
780 /// its value as a ListInit, throwing an exception if the field does not exist
781 /// or if the value is not the right type.
783 ListInit *getValueAsListInit(const std::string &FieldName) const;
785 /// getValueAsDef - This method looks up the specified field and returns its
786 /// value as a Record, throwing an exception if the field does not exist or if
787 /// the value is not the right type.
789 Record *getValueAsDef(const std::string &FieldName) const;
791 /// getValueAsBit - This method looks up the specified field and returns its
792 /// value as a bit, throwing an exception if the field does not exist or if
793 /// the value is not the right type.
795 bool getValueAsBit(const std::string &FieldName) const;
797 /// getValueAsInt - This method looks up the specified field and returns its
798 /// value as an int, throwing an exception if the field does not exist or if
799 /// the value is not the right type.
801 int getValueAsInt(const std::string &FieldName) const;
803 /// getValueAsDag - This method looks up the specified field and returns its
804 /// value as an Dag, throwing an exception if the field does not exist or if
805 /// the value is not the right type.
807 DagInit *getValueAsDag(const std::string &FieldName) const;
810 std::ostream &operator<<(std::ostream &OS, const Record &R);
813 std::map<std::string, Record*> Classes, Defs;
816 for (std::map<std::string, Record*>::iterator I = Classes.begin(),
817 E = Classes.end(); I != E; ++I)
819 for (std::map<std::string, Record*>::iterator I = Defs.begin(),
820 E = Defs.end(); I != E; ++I)
824 const std::map<std::string, Record*> &getClasses() const { return Classes; }
825 const std::map<std::string, Record*> &getDefs() const { return Defs; }
827 Record *getClass(const std::string &Name) const {
828 std::map<std::string, Record*>::const_iterator I = Classes.find(Name);
829 return I == Classes.end() ? 0 : I->second;
831 Record *getDef(const std::string &Name) const {
832 std::map<std::string, Record*>::const_iterator I = Defs.find(Name);
833 return I == Defs.end() ? 0 : I->second;
835 void addClass(Record *R) {
836 assert(getClass(R->getName()) == 0 && "Class already exists!");
837 Classes.insert(std::make_pair(R->getName(), R));
839 void addDef(Record *R) {
840 assert(getDef(R->getName()) == 0 && "Def already exists!");
841 Defs.insert(std::make_pair(R->getName(), R));
844 //===--------------------------------------------------------------------===//
845 // High-level helper methods, useful for tablegen backends...
847 /// getAllDerivedDefinitions - This method returns all concrete definitions
848 /// that derive from the specified class name. If a class with the specified
849 /// name does not exist, an exception is thrown.
851 getAllDerivedDefinitions(const std::string &ClassName) const;
857 std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK);
859 extern RecordKeeper Records;
861 } // End llvm namespace