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