TableGenBackends.h 3.7 KB

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