PageRenderTime 61ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/3rd_party/llvm/include/llvm/TableGen/Record.h

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