TableGenBackends.h revision 243830
1239310Sdim//===- TableGenBackends.h - Declarations for LLVM TableGen Backends -------===//
2239310Sdim//
3239310Sdim//                     The LLVM Compiler Infrastructure
4239310Sdim//
5239310Sdim// This file is distributed under the University of Illinois Open Source
6239310Sdim// License. See LICENSE.TXT for details.
7239310Sdim//
8239310Sdim//===----------------------------------------------------------------------===//
9239310Sdim//
10239310Sdim// This file contains the declarations for all of the LLVM TableGen
11239310Sdim// backends. A "TableGen backend" is just a function. See below for a
12239310Sdim// precise description.
13239310Sdim//
14239310Sdim//===----------------------------------------------------------------------===//
15239310Sdim
16239310Sdim
17239310Sdim// A TableGen backend is a function that looks like
18239310Sdim//
19239310Sdim//    EmitFoo(RecordKeeper &RK, raw_ostream &OS /*, anything else you need */ )
20239310Sdim//
21239310Sdim// What you do inside of that function is up to you, but it will usually
22239310Sdim// involve generating C++ code to the provided raw_ostream.
23239310Sdim//
24239310Sdim// The RecordKeeper is just a top-level container for an in-memory
25239310Sdim// representation of the data encoded in the TableGen file. What a TableGen
26239310Sdim// backend does is walk around that in-memory representation and generate
27239310Sdim// stuff based on the information it contains.
28239310Sdim//
29239310Sdim// The in-memory representation is a node-graph (think of it like JSON but
30239310Sdim// with a richer ontology of types), where the nodes are subclasses of
31239310Sdim// Record. The methods `getClass`, `getDef` are the basic interface to
32239310Sdim// access the node-graph.  RecordKeeper also provides a handy method
33239310Sdim// `getAllDerivedDefinitions`. Consult "include/llvm/TableGen/Record.h" for
34239310Sdim// the exact interfaces provided by Record's and RecordKeeper.
35239310Sdim//
36239310Sdim// A common pattern for TableGen backends is for the EmitFoo function to
37239310Sdim// instantiate a class which holds some context for the generation process,
38239310Sdim// and then have most of the work happen in that class's methods. This
39239310Sdim// pattern partly has historical roots in the previous TableGen backend API
40239310Sdim// that involved a class and an invocation like `FooEmitter(RK).run(OS)`.
41239310Sdim//
42239310Sdim// Remember to wrap private things in an anonymous namespace. For most
43239310Sdim// backends, this means that the EmitFoo function is the only thing not in
44239310Sdim// the anonymous namespace.
45239310Sdim
46239310Sdim
47239310Sdim// FIXME: Reorganize TableGen so that build dependencies can be more
48239310Sdim// accurately expressed. Currently, touching any of the emitters (or
49239310Sdim// anything that they transitively depend on) causes everything dependent
50239310Sdim// on TableGen to be rebuilt (this includes all the targets!). Perhaps have
51239310Sdim// a standalone TableGen binary and have the backends be loadable modules
52239310Sdim// of some sort; then the dependency could be expressed as being on the
53239310Sdim// module, and all the modules would have a common dependency on the
54239310Sdim// TableGen binary with as few dependencies as possible on the rest of
55239310Sdim// LLVM.
56239310Sdim
57239310Sdim
58239310Sdimnamespace llvm {
59239310Sdim
60239310Sdimclass raw_ostream;
61239310Sdimclass RecordKeeper;
62239310Sdim
63239310Sdimvoid EmitIntrinsics(RecordKeeper &RK, raw_ostream &OS, bool TargetOnly = false);
64239310Sdimvoid EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS);
65239310Sdimvoid EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS);
66239310Sdimvoid EmitCallingConv(RecordKeeper &RK, raw_ostream &OS);
67239310Sdimvoid EmitCodeEmitter(RecordKeeper &RK, raw_ostream &OS);
68239310Sdimvoid EmitDAGISel(RecordKeeper &RK, raw_ostream &OS);
69239310Sdimvoid EmitDFAPacketizer(RecordKeeper &RK, raw_ostream &OS);
70239310Sdimvoid EmitDisassembler(RecordKeeper &RK, raw_ostream &OS);
71239310Sdimvoid EmitEnhancedDisassemblerInfo(RecordKeeper &RK, raw_ostream &OS);
72239310Sdimvoid EmitFastISel(RecordKeeper &RK, raw_ostream &OS);
73239310Sdimvoid EmitInstrInfo(RecordKeeper &RK, raw_ostream &OS);
74239310Sdimvoid EmitPseudoLowering(RecordKeeper &RK, raw_ostream &OS);
75239310Sdimvoid EmitRegisterInfo(RecordKeeper &RK, raw_ostream &OS);
76239310Sdimvoid EmitSubtarget(RecordKeeper &RK, raw_ostream &OS);
77243830Sdimvoid EmitMapTable(RecordKeeper &RK, raw_ostream &OS);
78239310Sdim
79239310Sdim} // End llvm namespace
80