blob: 135ec65c0f954c740d69bc73679c36d886a66e2a [file] [log] [blame]
Jakob Stoklund Olesene6aed132012-06-11 15:37:55 +00001//===- TableGenBackends.h - Declarations for LLVM TableGen Backends -------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Jakob Stoklund Olesene6aed132012-06-11 15:37:55 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the declarations for all of the LLVM TableGen
10// backends. A "TableGen backend" is just a function. See below for a
11// precise description.
12//
13//===----------------------------------------------------------------------===//
14
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H
16#define LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H
Jakob Stoklund Olesene6aed132012-06-11 15:37:55 +000017
18// A TableGen backend is a function that looks like
19//
20// EmitFoo(RecordKeeper &RK, raw_ostream &OS /*, anything else you need */ )
21//
22// What you do inside of that function is up to you, but it will usually
23// involve generating C++ code to the provided raw_ostream.
24//
25// The RecordKeeper is just a top-level container for an in-memory
26// representation of the data encoded in the TableGen file. What a TableGen
27// backend does is walk around that in-memory representation and generate
28// stuff based on the information it contains.
29//
30// The in-memory representation is a node-graph (think of it like JSON but
31// with a richer ontology of types), where the nodes are subclasses of
32// Record. The methods `getClass`, `getDef` are the basic interface to
33// access the node-graph. RecordKeeper also provides a handy method
34// `getAllDerivedDefinitions`. Consult "include/llvm/TableGen/Record.h" for
35// the exact interfaces provided by Record's and RecordKeeper.
36//
37// A common pattern for TableGen backends is for the EmitFoo function to
38// instantiate a class which holds some context for the generation process,
39// and then have most of the work happen in that class's methods. This
40// pattern partly has historical roots in the previous TableGen backend API
41// that involved a class and an invocation like `FooEmitter(RK).run(OS)`.
42//
43// Remember to wrap private things in an anonymous namespace. For most
44// backends, this means that the EmitFoo function is the only thing not in
45// the anonymous namespace.
46
47
48// FIXME: Reorganize TableGen so that build dependencies can be more
49// accurately expressed. Currently, touching any of the emitters (or
50// anything that they transitively depend on) causes everything dependent
51// on TableGen to be rebuilt (this includes all the targets!). Perhaps have
52// a standalone TableGen binary and have the backends be loadable modules
53// of some sort; then the dependency could be expressed as being on the
54// module, and all the modules would have a common dependency on the
55// TableGen binary with as few dependencies as possible on the rest of
56// LLVM.
57
58
59namespace llvm {
60
61class raw_ostream;
62class RecordKeeper;
63
Reid Klecknerf5890e42018-06-23 02:02:38 +000064void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS,
65 bool TargetOnly = false);
66void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
67 bool TargetOnly = false);
Jakob Stoklund Olesene6aed132012-06-11 15:37:55 +000068void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS);
69void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS);
70void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS);
71void EmitCodeEmitter(RecordKeeper &RK, raw_ostream &OS);
72void EmitDAGISel(RecordKeeper &RK, raw_ostream &OS);
73void EmitDFAPacketizer(RecordKeeper &RK, raw_ostream &OS);
74void EmitDisassembler(RecordKeeper &RK, raw_ostream &OS);
Jakob Stoklund Olesene6aed132012-06-11 15:37:55 +000075void EmitFastISel(RecordKeeper &RK, raw_ostream &OS);
76void EmitInstrInfo(RecordKeeper &RK, raw_ostream &OS);
Oliver Stannard174fdef2017-11-14 15:35:15 +000077void EmitInstrDocs(RecordKeeper &RK, raw_ostream &OS);
Jakob Stoklund Olesene6aed132012-06-11 15:37:55 +000078void EmitPseudoLowering(RecordKeeper &RK, raw_ostream &OS);
Sameer AbuAsalc1b0e662018-04-06 21:07:05 +000079void EmitCompressInst(RecordKeeper &RK, raw_ostream &OS);
Jakob Stoklund Olesene6aed132012-06-11 15:37:55 +000080void EmitRegisterInfo(RecordKeeper &RK, raw_ostream &OS);
81void EmitSubtarget(RecordKeeper &RK, raw_ostream &OS);
Sebastian Pop5c87daf2012-10-25 15:54:06 +000082void EmitMapTable(RecordKeeper &RK, raw_ostream &OS);
Michael J. Spencer41ee0412012-12-05 00:29:32 +000083void EmitOptParser(RecordKeeper &RK, raw_ostream &OS);
Sean Silvacdd21b32013-03-21 23:40:38 +000084void EmitCTags(RecordKeeper &RK, raw_ostream &OS);
Akira Hatanakad9326792015-11-11 20:35:42 +000085void EmitAttributes(RecordKeeper &RK, raw_ostream &OS);
Tim Northovere6ae6762016-07-05 21:23:04 +000086void EmitSearchableTables(RecordKeeper &RK, raw_ostream &OS);
Ahmed Bougacha36f70352016-12-21 23:26:20 +000087void EmitGlobalISel(RecordKeeper &RK, raw_ostream &OS);
Ayman Musa850fc972017-03-07 08:11:19 +000088void EmitX86EVEX2VEXTables(RecordKeeper &RK, raw_ostream &OS);
Ayman Musa993339b2017-10-08 09:20:32 +000089void EmitX86FoldTables(RecordKeeper &RK, raw_ostream &OS);
Daniel Sandersd64d50242017-01-19 11:15:55 +000090void EmitRegisterBank(RecordKeeper &RK, raw_ostream &OS);
Clement Courbet41c8af32018-10-25 07:44:01 +000091void EmitExegesis(RecordKeeper &RK, raw_ostream &OS);
Jakob Stoklund Olesene6aed132012-06-11 15:37:55 +000092
93} // End llvm namespace
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000094
95#endif