Paul C. Anagnostopoulos | 848d66f | 2020-09-21 13:56:06 -0400 | [diff] [blame] | 1 | //===- SkeletonEmitter.cpp - Skeleton TableGen backend -*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This Tablegen backend emits ... |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "llvm/ADT/ArrayRef.h" |
| 14 | #include "llvm/ADT/DenseMap.h" |
| 15 | #include "llvm/ADT/StringExtras.h" |
| 16 | #include "llvm/Support/Format.h" |
| 17 | #include "llvm/Support/MemoryBuffer.h" |
| 18 | #include "llvm/Support/SourceMgr.h" |
| 19 | #include "llvm/TableGen/Error.h" |
| 20 | #include "llvm/TableGen/Record.h" |
| 21 | #include "llvm/TableGen/TableGenBackend.h" |
| 22 | #include <algorithm> |
| 23 | #include <set> |
| 24 | #include <string> |
| 25 | #include <vector> |
| 26 | |
| 27 | #define DEBUG_TYPE "skeleton-emitter" |
| 28 | |
| 29 | using namespace llvm; |
| 30 | |
| 31 | namespace { |
| 32 | |
| 33 | // Any helper data structures can be defined here. Some backends use |
| 34 | // structs to collect information from the records. |
| 35 | |
| 36 | class SkeletonEmitter { |
| 37 | private: |
| 38 | RecordKeeper &Records; |
| 39 | |
| 40 | public: |
| 41 | SkeletonEmitter(RecordKeeper &RK) : Records(RK) {} |
| 42 | |
| 43 | void run(raw_ostream &OS); |
Paul C. Anagnostopoulos | 0c1bb4f8 | 2020-09-22 13:58:54 -0400 | [diff] [blame] | 44 | }; // emitter class |
Paul C. Anagnostopoulos | 848d66f | 2020-09-21 13:56:06 -0400 | [diff] [blame] | 45 | |
Paul C. Anagnostopoulos | 0c1bb4f8 | 2020-09-22 13:58:54 -0400 | [diff] [blame] | 46 | } // anonymous namespace |
Paul C. Anagnostopoulos | 848d66f | 2020-09-21 13:56:06 -0400 | [diff] [blame] | 47 | |
| 48 | void SkeletonEmitter::run(raw_ostream &OS) { |
| 49 | emitSourceFileHeader("Skeleton data structures", OS); |
Paul C. Anagnostopoulos | 21f5f50 | 2020-09-22 15:55:51 -0400 | [diff] [blame] | 50 | |
| 51 | (void)Records; // To suppress unused variable warning; remove on use. |
Paul C. Anagnostopoulos | 848d66f | 2020-09-21 13:56:06 -0400 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | namespace llvm { |
| 55 | |
| 56 | // The only thing that should be in the llvm namespace is the |
| 57 | // emitter entry point function. |
| 58 | |
| 59 | void EmitSkeleton(RecordKeeper &RK, raw_ostream &OS) { |
| 60 | // Instantiate the emitter class and invoke run(). |
| 61 | SkeletonEmitter(RK).run(OS); |
| 62 | } |
| 63 | |
Paul C. Anagnostopoulos | 0c1bb4f8 | 2020-09-22 13:58:54 -0400 | [diff] [blame] | 64 | } // namespace llvm |