1*9880d681SAndroid Build Coastguard Worker //===- TableGenBackends.h - Declarations for LLVM TableGen Backends -------===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file contains the declarations for all of the LLVM TableGen 11*9880d681SAndroid Build Coastguard Worker // backends. A "TableGen backend" is just a function. See below for a 12*9880d681SAndroid Build Coastguard Worker // precise description. 13*9880d681SAndroid Build Coastguard Worker // 14*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H 17*9880d681SAndroid Build Coastguard Worker #define LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker // A TableGen backend is a function that looks like 20*9880d681SAndroid Build Coastguard Worker // 21*9880d681SAndroid Build Coastguard Worker // EmitFoo(RecordKeeper &RK, raw_ostream &OS /*, anything else you need */ ) 22*9880d681SAndroid Build Coastguard Worker // 23*9880d681SAndroid Build Coastguard Worker // What you do inside of that function is up to you, but it will usually 24*9880d681SAndroid Build Coastguard Worker // involve generating C++ code to the provided raw_ostream. 25*9880d681SAndroid Build Coastguard Worker // 26*9880d681SAndroid Build Coastguard Worker // The RecordKeeper is just a top-level container for an in-memory 27*9880d681SAndroid Build Coastguard Worker // representation of the data encoded in the TableGen file. What a TableGen 28*9880d681SAndroid Build Coastguard Worker // backend does is walk around that in-memory representation and generate 29*9880d681SAndroid Build Coastguard Worker // stuff based on the information it contains. 30*9880d681SAndroid Build Coastguard Worker // 31*9880d681SAndroid Build Coastguard Worker // The in-memory representation is a node-graph (think of it like JSON but 32*9880d681SAndroid Build Coastguard Worker // with a richer ontology of types), where the nodes are subclasses of 33*9880d681SAndroid Build Coastguard Worker // Record. The methods `getClass`, `getDef` are the basic interface to 34*9880d681SAndroid Build Coastguard Worker // access the node-graph. RecordKeeper also provides a handy method 35*9880d681SAndroid Build Coastguard Worker // `getAllDerivedDefinitions`. Consult "include/llvm/TableGen/Record.h" for 36*9880d681SAndroid Build Coastguard Worker // the exact interfaces provided by Record's and RecordKeeper. 37*9880d681SAndroid Build Coastguard Worker // 38*9880d681SAndroid Build Coastguard Worker // A common pattern for TableGen backends is for the EmitFoo function to 39*9880d681SAndroid Build Coastguard Worker // instantiate a class which holds some context for the generation process, 40*9880d681SAndroid Build Coastguard Worker // and then have most of the work happen in that class's methods. This 41*9880d681SAndroid Build Coastguard Worker // pattern partly has historical roots in the previous TableGen backend API 42*9880d681SAndroid Build Coastguard Worker // that involved a class and an invocation like `FooEmitter(RK).run(OS)`. 43*9880d681SAndroid Build Coastguard Worker // 44*9880d681SAndroid Build Coastguard Worker // Remember to wrap private things in an anonymous namespace. For most 45*9880d681SAndroid Build Coastguard Worker // backends, this means that the EmitFoo function is the only thing not in 46*9880d681SAndroid Build Coastguard Worker // the anonymous namespace. 47*9880d681SAndroid Build Coastguard Worker 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Worker // FIXME: Reorganize TableGen so that build dependencies can be more 50*9880d681SAndroid Build Coastguard Worker // accurately expressed. Currently, touching any of the emitters (or 51*9880d681SAndroid Build Coastguard Worker // anything that they transitively depend on) causes everything dependent 52*9880d681SAndroid Build Coastguard Worker // on TableGen to be rebuilt (this includes all the targets!). Perhaps have 53*9880d681SAndroid Build Coastguard Worker // a standalone TableGen binary and have the backends be loadable modules 54*9880d681SAndroid Build Coastguard Worker // of some sort; then the dependency could be expressed as being on the 55*9880d681SAndroid Build Coastguard Worker // module, and all the modules would have a common dependency on the 56*9880d681SAndroid Build Coastguard Worker // TableGen binary with as few dependencies as possible on the rest of 57*9880d681SAndroid Build Coastguard Worker // LLVM. 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker 60*9880d681SAndroid Build Coastguard Worker namespace llvm { 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Worker class raw_ostream; 63*9880d681SAndroid Build Coastguard Worker class RecordKeeper; 64*9880d681SAndroid Build Coastguard Worker 65*9880d681SAndroid Build Coastguard Worker void EmitIntrinsics(RecordKeeper &RK, raw_ostream &OS, bool TargetOnly = false); 66*9880d681SAndroid Build Coastguard Worker void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS); 67*9880d681SAndroid Build Coastguard Worker void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS); 68*9880d681SAndroid Build Coastguard Worker void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS); 69*9880d681SAndroid Build Coastguard Worker void EmitCodeEmitter(RecordKeeper &RK, raw_ostream &OS); 70*9880d681SAndroid Build Coastguard Worker void EmitDAGISel(RecordKeeper &RK, raw_ostream &OS); 71*9880d681SAndroid Build Coastguard Worker void EmitDFAPacketizer(RecordKeeper &RK, raw_ostream &OS); 72*9880d681SAndroid Build Coastguard Worker void EmitDisassembler(RecordKeeper &RK, raw_ostream &OS); 73*9880d681SAndroid Build Coastguard Worker void EmitFastISel(RecordKeeper &RK, raw_ostream &OS); 74*9880d681SAndroid Build Coastguard Worker void EmitInstrInfo(RecordKeeper &RK, raw_ostream &OS); 75*9880d681SAndroid Build Coastguard Worker void EmitPseudoLowering(RecordKeeper &RK, raw_ostream &OS); 76*9880d681SAndroid Build Coastguard Worker void EmitRegisterInfo(RecordKeeper &RK, raw_ostream &OS); 77*9880d681SAndroid Build Coastguard Worker void EmitSubtarget(RecordKeeper &RK, raw_ostream &OS); 78*9880d681SAndroid Build Coastguard Worker void EmitMapTable(RecordKeeper &RK, raw_ostream &OS); 79*9880d681SAndroid Build Coastguard Worker void EmitOptParser(RecordKeeper &RK, raw_ostream &OS); 80*9880d681SAndroid Build Coastguard Worker void EmitCTags(RecordKeeper &RK, raw_ostream &OS); 81*9880d681SAndroid Build Coastguard Worker void EmitAttributes(RecordKeeper &RK, raw_ostream &OS); 82*9880d681SAndroid Build Coastguard Worker void EmitSearchableTables(RecordKeeper &RK, raw_ostream &OS); 83*9880d681SAndroid Build Coastguard Worker 84*9880d681SAndroid Build Coastguard Worker } // End llvm namespace 85*9880d681SAndroid Build Coastguard Worker 86*9880d681SAndroid Build Coastguard Worker #endif 87