1239310Sdim//===- TableGenBackends.h - Declarations for LLVM TableGen Backends -------===//
2239310Sdim//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6239310Sdim//
7239310Sdim//===----------------------------------------------------------------------===//
8239310Sdim//
9239310Sdim// This file contains the declarations for all of the LLVM TableGen
10239310Sdim// backends. A "TableGen backend" is just a function. See below for a
11239310Sdim// precise description.
12239310Sdim//
13239310Sdim//===----------------------------------------------------------------------===//
14239310Sdim
15280031Sdim#ifndef LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H
16280031Sdim#define LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H
17239310Sdim
18239310Sdim// A TableGen backend is a function that looks like
19239310Sdim//
20239310Sdim//    EmitFoo(RecordKeeper &RK, raw_ostream &OS /*, anything else you need */ )
21239310Sdim//
22239310Sdim// What you do inside of that function is up to you, but it will usually
23239310Sdim// involve generating C++ code to the provided raw_ostream.
24239310Sdim//
25239310Sdim// The RecordKeeper is just a top-level container for an in-memory
26239310Sdim// representation of the data encoded in the TableGen file. What a TableGen
27239310Sdim// backend does is walk around that in-memory representation and generate
28239310Sdim// stuff based on the information it contains.
29239310Sdim//
30239310Sdim// The in-memory representation is a node-graph (think of it like JSON but
31239310Sdim// with a richer ontology of types), where the nodes are subclasses of
32239310Sdim// Record. The methods `getClass`, `getDef` are the basic interface to
33239310Sdim// access the node-graph.  RecordKeeper also provides a handy method
34239310Sdim// `getAllDerivedDefinitions`. Consult "include/llvm/TableGen/Record.h" for
35239310Sdim// the exact interfaces provided by Record's and RecordKeeper.
36239310Sdim//
37239310Sdim// A common pattern for TableGen backends is for the EmitFoo function to
38239310Sdim// instantiate a class which holds some context for the generation process,
39239310Sdim// and then have most of the work happen in that class's methods. This
40239310Sdim// pattern partly has historical roots in the previous TableGen backend API
41239310Sdim// that involved a class and an invocation like `FooEmitter(RK).run(OS)`.
42239310Sdim//
43239310Sdim// Remember to wrap private things in an anonymous namespace. For most
44239310Sdim// backends, this means that the EmitFoo function is the only thing not in
45239310Sdim// the anonymous namespace.
46239310Sdim
47239310Sdim
48239310Sdim// FIXME: Reorganize TableGen so that build dependencies can be more
49239310Sdim// accurately expressed. Currently, touching any of the emitters (or
50239310Sdim// anything that they transitively depend on) causes everything dependent
51239310Sdim// on TableGen to be rebuilt (this includes all the targets!). Perhaps have
52239310Sdim// a standalone TableGen binary and have the backends be loadable modules
53239310Sdim// of some sort; then the dependency could be expressed as being on the
54239310Sdim// module, and all the modules would have a common dependency on the
55239310Sdim// TableGen binary with as few dependencies as possible on the rest of
56239310Sdim// LLVM.
57239310Sdim
58239310Sdim
59239310Sdimnamespace llvm {
60239310Sdim
61239310Sdimclass raw_ostream;
62239310Sdimclass RecordKeeper;
63239310Sdim
64360784Sdimvoid EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS);
65360784Sdimvoid EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS);
66239310Sdimvoid EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS);
67239310Sdimvoid EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS);
68239310Sdimvoid EmitCallingConv(RecordKeeper &RK, raw_ostream &OS);
69239310Sdimvoid EmitCodeEmitter(RecordKeeper &RK, raw_ostream &OS);
70239310Sdimvoid EmitDAGISel(RecordKeeper &RK, raw_ostream &OS);
71239310Sdimvoid EmitDFAPacketizer(RecordKeeper &RK, raw_ostream &OS);
72239310Sdimvoid EmitDisassembler(RecordKeeper &RK, raw_ostream &OS);
73239310Sdimvoid EmitFastISel(RecordKeeper &RK, raw_ostream &OS);
74239310Sdimvoid EmitInstrInfo(RecordKeeper &RK, raw_ostream &OS);
75327952Sdimvoid EmitInstrDocs(RecordKeeper &RK, raw_ostream &OS);
76239310Sdimvoid EmitPseudoLowering(RecordKeeper &RK, raw_ostream &OS);
77341825Sdimvoid EmitCompressInst(RecordKeeper &RK, raw_ostream &OS);
78239310Sdimvoid EmitRegisterInfo(RecordKeeper &RK, raw_ostream &OS);
79239310Sdimvoid EmitSubtarget(RecordKeeper &RK, raw_ostream &OS);
80243830Sdimvoid EmitMapTable(RecordKeeper &RK, raw_ostream &OS);
81249423Sdimvoid EmitOptParser(RecordKeeper &RK, raw_ostream &OS);
82360784Sdimvoid EmitOptRST(RecordKeeper &RK, raw_ostream &OS);
83249423Sdimvoid EmitCTags(RecordKeeper &RK, raw_ostream &OS);
84296417Sdimvoid EmitAttributes(RecordKeeper &RK, raw_ostream &OS);
85309124Sdimvoid EmitSearchableTables(RecordKeeper &RK, raw_ostream &OS);
86314564Sdimvoid EmitGlobalISel(RecordKeeper &RK, raw_ostream &OS);
87360784Sdimvoid EmitGICombiner(RecordKeeper &RK, raw_ostream &OS);
88321369Sdimvoid EmitX86EVEX2VEXTables(RecordKeeper &RK, raw_ostream &OS);
89327952Sdimvoid EmitX86FoldTables(RecordKeeper &RK, raw_ostream &OS);
90321369Sdimvoid EmitRegisterBank(RecordKeeper &RK, raw_ostream &OS);
91344779Sdimvoid EmitExegesis(RecordKeeper &RK, raw_ostream &OS);
92360784Sdimvoid EmitAutomata(RecordKeeper &RK, raw_ostream &OS);
93239310Sdim
94239310Sdim} // End llvm namespace
95280031Sdim
96280031Sdim#endif
97