Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 1 | //===- TableGenBackend.h - Base class for TableGen Backends -----*- C++ -*-===// |
| 2 | // |
| 3 | // The TableGenBackend class is provided as a common interface for all TableGen |
| 4 | // backends. It provides useful services and an standardized interface. |
| 5 | // |
| 6 | //===----------------------------------------------------------------------===// |
| 7 | |
| 8 | #ifndef TABLEGENBACKEND_H |
| 9 | #define TABLEGENBACKEND_H |
| 10 | |
| 11 | #include <string> |
| 12 | #include <iosfwd> |
Chris Lattner | 18a6a94 | 2003-08-06 04:31:26 +0000 | [diff] [blame] | 13 | class Record; |
| 14 | class RecordKeeper; |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 15 | |
| 16 | struct TableGenBackend { |
Chris Lattner | a7ac3cf | 2003-08-06 05:39:03 +0000 | [diff] [blame^] | 17 | virtual ~TableGenBackend() {} |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 18 | |
| 19 | // run - All TableGen backends should implement the run method, which should |
| 20 | // be the main entry point. |
| 21 | virtual void run(std::ostream &OS) = 0; |
| 22 | |
| 23 | |
| 24 | public: // Useful helper routines... |
Chris Lattner | 18a6a94 | 2003-08-06 04:31:26 +0000 | [diff] [blame] | 25 | /// EmitSourceFileHeader - Output a LLVM style file header to the specified |
| 26 | /// ostream. |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 27 | void EmitSourceFileHeader(const std::string &Desc, std::ostream &OS) const; |
| 28 | |
Chris Lattner | 18a6a94 | 2003-08-06 04:31:26 +0000 | [diff] [blame] | 29 | /// getQualifiedName - Return the name of the specified record, with a |
| 30 | /// namespace qualifier if the record contains one. |
| 31 | std::string getQualifiedName(Record *R) const; |
| 32 | |
| 33 | /// getTarget - Return the current instance of the Target class. |
| 34 | Record *getTarget(RecordKeeper &RC) const; |
Chris Lattner | 2c0f2c7 | 2003-08-06 04:23:04 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | #endif |