1 //===- SkeletonEmitter.cpp - Skeleton TableGen backend -*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This Tablegen backend emits ...
11 //===----------------------------------------------------------------------===//
13 #include "llvm/ADT/DenseMapInfo.h"
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/TableGen/TableGenBackend.h"
17 #define DEBUG_TYPE "skeleton-emitter"
28 // Any helper data structures can be defined here. Some backends use
29 // structs to collect information from the records.
31 class SkeletonEmitter
{
33 RecordKeeper
&Records
;
36 SkeletonEmitter(RecordKeeper
&RK
) : Records(RK
) {}
38 void run(raw_ostream
&OS
);
41 } // anonymous namespace
43 void SkeletonEmitter::run(raw_ostream
&OS
) {
44 emitSourceFileHeader("Skeleton data structures", OS
);
46 (void)Records
; // To suppress unused variable warning; remove on use.
49 // Choose either option A or B.
51 //===----------------------------------------------------------------------===//
52 // Option A: Register the backed as class <SkeletonEmitter>
53 static TableGen::Emitter::OptClass
<SkeletonEmitter
>
54 X("gen-skeleton-class", "Generate example skeleton class");
56 //===----------------------------------------------------------------------===//
57 // Option B: Register "EmitSkeleton" directly
58 // The emitter entry may be private scope.
59 static void EmitSkeleton(RecordKeeper
&RK
, raw_ostream
&OS
) {
60 // Instantiate the emitter class and invoke run().
61 SkeletonEmitter(RK
).run(OS
);
64 static TableGen::Emitter::Opt
Y("gen-skeleton-entry", EmitSkeleton
,
65 "Generate example skeleton entry");