LLVM 19.0.0git
TableGenBackendSkeleton.cpp
Go to the documentation of this file.
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/StringRef.h"
15
16#define DEBUG_TYPE "skeleton-emitter"
17
18namespace llvm {
19class RecordKeeper;
20class raw_ostream;
21} // namespace llvm
22
23using namespace llvm;
24
25namespace {
26
27// Any helper data structures can be defined here. Some backends use
28// structs to collect information from the records.
29
30class SkeletonEmitter {
31private:
33
34public:
35 SkeletonEmitter(RecordKeeper &RK) : Records(RK) {}
36
37 void run(raw_ostream &OS);
38}; // emitter class
39
40} // anonymous namespace
41
42void SkeletonEmitter::run(raw_ostream &OS) {
43 emitSourceFileHeader("Skeleton data structures", OS);
44
45 (void)Records; // To suppress unused variable warning; remove on use.
46}
47
48// Choose either option A or B.
49
50//===----------------------------------------------------------------------===//
51// Option A: Register the backed as class <SkeletonEmitter>
53 X("gen-skeleton-class", "Generate example skeleton class");
54
55//===----------------------------------------------------------------------===//
56// Option B: Register "EmitSkeleton" directly
57// The emitter entry may be private scope.
59 // Instantiate the emitter class and invoke run().
60 SkeletonEmitter(RK).run(OS);
61}
62
63static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton,
64 "Generate example skeleton entry");
raw_pwrite_stream & OS
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static void EmitSkeleton(RecordKeeper &RK, raw_ostream &OS)
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
llvm::SmallVector< std::shared_ptr< RecordsSlice >, 4 > Records
Definition: RecordsSlice.h:197
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void emitSourceFileHeader(StringRef Desc, raw_ostream &OS, const RecordKeeper &Record=RecordKeeper())
emitSourceFileHeader - Output an LLVM style file header to the specified raw_ostream.