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