xref: /freebsd-src/contrib/llvm-project/llvm/lib/TableGen/TableGenBackendSkeleton.cpp (revision 1fd87a682ad7442327078e1eeb63edc4258f9815)
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 
13*1fd87a68SDimitry Andric #include "llvm/ADT/DenseMapInfo.h"
14*1fd87a68SDimitry Andric #include "llvm/ADT/StringRef.h"
15e8d8bef9SDimitry Andric #include "llvm/TableGen/TableGenBackend.h"
16e8d8bef9SDimitry Andric 
17e8d8bef9SDimitry Andric #define DEBUG_TYPE "skeleton-emitter"
18e8d8bef9SDimitry Andric 
19*1fd87a68SDimitry Andric namespace llvm {
20*1fd87a68SDimitry Andric class RecordKeeper;
21*1fd87a68SDimitry Andric class raw_ostream;
22*1fd87a68SDimitry Andric } // namespace llvm
23*1fd87a68SDimitry Andric 
24e8d8bef9SDimitry Andric using namespace llvm;
25e8d8bef9SDimitry Andric 
26e8d8bef9SDimitry Andric namespace {
27e8d8bef9SDimitry Andric 
28e8d8bef9SDimitry Andric // Any helper data structures can be defined here. Some backends use
29e8d8bef9SDimitry Andric // structs to collect information from the records.
30e8d8bef9SDimitry Andric 
31e8d8bef9SDimitry Andric class SkeletonEmitter {
32e8d8bef9SDimitry Andric private:
33e8d8bef9SDimitry Andric   RecordKeeper &Records;
34e8d8bef9SDimitry Andric 
35e8d8bef9SDimitry Andric public:
36e8d8bef9SDimitry Andric   SkeletonEmitter(RecordKeeper &RK) : Records(RK) {}
37e8d8bef9SDimitry Andric 
38e8d8bef9SDimitry Andric   void run(raw_ostream &OS);
39e8d8bef9SDimitry Andric }; // emitter class
40e8d8bef9SDimitry Andric 
41e8d8bef9SDimitry Andric } // anonymous namespace
42e8d8bef9SDimitry Andric 
43e8d8bef9SDimitry Andric void SkeletonEmitter::run(raw_ostream &OS) {
44e8d8bef9SDimitry Andric   emitSourceFileHeader("Skeleton data structures", OS);
45e8d8bef9SDimitry Andric 
46e8d8bef9SDimitry Andric   (void)Records; // To suppress unused variable warning; remove on use.
47e8d8bef9SDimitry Andric }
48e8d8bef9SDimitry Andric 
49e8d8bef9SDimitry Andric namespace llvm {
50e8d8bef9SDimitry Andric 
51e8d8bef9SDimitry Andric // The only thing that should be in the llvm namespace is the
52e8d8bef9SDimitry Andric // emitter entry point function.
53e8d8bef9SDimitry Andric 
54e8d8bef9SDimitry Andric void EmitSkeleton(RecordKeeper &RK, raw_ostream &OS) {
55e8d8bef9SDimitry Andric   // Instantiate the emitter class and invoke run().
56e8d8bef9SDimitry Andric   SkeletonEmitter(RK).run(OS);
57e8d8bef9SDimitry Andric }
58e8d8bef9SDimitry Andric 
59e8d8bef9SDimitry Andric } // namespace llvm
60