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