LLVM 20.0.0git
TableGenBackend.h
Go to the documentation of this file.
1//===- llvm/TableGen/TableGenBackend.h - Backend utilities ------*- 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// Useful utilities for TableGen backends.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TABLEGEN_TABLEGENBACKEND_H
14#define LLVM_TABLEGEN_TABLEGENBACKEND_H
15
16#include "llvm/ADT/StringRef.h"
20
21namespace llvm {
22
23class RecordKeeper;
24class raw_ostream;
25
26namespace TableGen::Emitter {
27using FnT = void (*)(RecordKeeper &Records, raw_ostream &OS);
28
30 static void *call();
31};
32
34
35struct Opt {
36 Opt(StringRef Name, FnT CB, StringRef Desc, bool ByDefault = false) {
37 if (ByDefault)
38 Action->setInitialValue(CB);
39 Action->getParser().addLiteralOption(Name, CB, Desc);
40 }
41};
42
43template <class EmitterC> class OptClass : Opt {
44 static void run(RecordKeeper &RK, raw_ostream &OS) { EmitterC(RK).run(OS); }
45
46public:
48};
49
50} // namespace TableGen::Emitter
51
52/// emitSourceFileHeader - Output an LLVM style file header to the specified
53/// raw_ostream.
56
57} // End llvm namespace
58
59#endif
std::string Name
raw_pwrite_stream & OS
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
Definition: ManagedStatic.h:83
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
OptClass(StringRef Name, StringRef Desc)
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
ManagedStatic< cl::opt< FnT >, OptCreatorT > Action
void(*)(RecordKeeper &Records, raw_ostream &OS) FnT
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.
Description of the encoding of one expression Op.
Opt(StringRef Name, FnT CB, StringRef Desc, bool ByDefault=false)