LLVM 17.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
14#include "llvm/ADT/StringRef.h"
16
17#define DEBUG_TYPE "skeleton-emitter"
18
19namespace llvm {
20class RecordKeeper;
21class raw_ostream;
22} // namespace llvm
23
24using namespace llvm;
25
26namespace {
27
28// Any helper data structures can be defined here. Some backends use
29// structs to collect information from the records.
30
31class SkeletonEmitter {
32private:
33 RecordKeeper &Records;
34
35public:
36 SkeletonEmitter(RecordKeeper &RK) : Records(RK) {}
37
38 void run(raw_ostream &OS);
39}; // emitter class
40
41} // anonymous namespace
42
43void SkeletonEmitter::run(raw_ostream &OS) {
44 emitSourceFileHeader("Skeleton data structures", OS);
45
46 (void)Records; // To suppress unused variable warning; remove on use.
47}
48
49// Choose either option A or B.
50
51//===----------------------------------------------------------------------===//
52// Option A: Register the backed as class <SkeletonEmitter>
54 X("gen-skeleton-class", "Generate example skeleton class");
55
56//===----------------------------------------------------------------------===//
57// Option B: Register "EmitSkeleton" directly
58// The emitter entry may be private scope.
60 // Instantiate the emitter class and invoke run().
61 SkeletonEmitter(RK).run(OS);
62}
63
64static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton,
65 "Generate example skeleton entry");
This file defines DenseMapInfo traits for DenseMap.
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
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)
emitSourceFileHeader - Output an LLVM style file header to the specified raw_ostream.