TableGenBackends.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //===- TableGenBackends.h - Declarations for LLVM TableGen Backends -------===//
  2. //
  3. // 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
  6. //
  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. #ifndef LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H
  15. #define LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H
  16. // A TableGen backend is a function that looks like
  17. //
  18. // EmitFoo(RecordKeeper &RK, raw_ostream &OS /*, anything else you need */ )
  19. //
  20. // What you do inside of that function is up to you, but it will usually
  21. // involve generating C++ code to the provided raw_ostream.
  22. //
  23. // The RecordKeeper is just a top-level container for an in-memory
  24. // representation of the data encoded in the TableGen file. What a TableGen
  25. // backend does is walk around that in-memory representation and generate
  26. // stuff based on the information it contains.
  27. //
  28. // The in-memory representation is a node-graph (think of it like JSON but
  29. // with a richer ontology of types), where the nodes are subclasses of
  30. // Record. The methods `getClass`, `getDef` are the basic interface to
  31. // access the node-graph. RecordKeeper also provides a handy method
  32. // `getAllDerivedDefinitions`. Consult "include/llvm/TableGen/Record.h" for
  33. // the exact interfaces provided by Record's and RecordKeeper.
  34. //
  35. // A common pattern for TableGen backends is for the EmitFoo function to
  36. // instantiate a class which holds some context for the generation process,
  37. // and then have most of the work happen in that class's methods. This
  38. // pattern partly has historical roots in the previous TableGen backend API
  39. // that involved a class and an invocation like `FooEmitter(RK).run(OS)`.
  40. //
  41. // Remember to wrap private things in an anonymous namespace. For most
  42. // backends, this means that the EmitFoo function is the only thing not in
  43. // the anonymous namespace.
  44. // FIXME: Reorganize TableGen so that build dependencies can be more
  45. // accurately expressed. Currently, touching any of the emitters (or
  46. // anything that they transitively depend on) causes everything dependent
  47. // on TableGen to be rebuilt (this includes all the targets!). Perhaps have
  48. // a standalone TableGen binary and have the backends be loadable modules
  49. // of some sort; then the dependency could be expressed as being on the
  50. // module, and all the modules would have a common dependency on the
  51. // TableGen binary with as few dependencies as possible on the rest of
  52. // LLVM.
  53. namespace llvm {
  54. class raw_ostream;
  55. class RecordKeeper;
  56. void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS);
  57. void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS);
  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 EmitInstrDocs(RecordKeeper &RK, raw_ostream &OS);
  68. void EmitPseudoLowering(RecordKeeper &RK, raw_ostream &OS);
  69. void EmitCompressInst(RecordKeeper &RK, raw_ostream &OS);
  70. void EmitRegisterInfo(RecordKeeper &RK, raw_ostream &OS);
  71. void EmitSubtarget(RecordKeeper &RK, raw_ostream &OS);
  72. void EmitMapTable(RecordKeeper &RK, raw_ostream &OS);
  73. void EmitOptParser(RecordKeeper &RK, raw_ostream &OS);
  74. void EmitOptRST(RecordKeeper &RK, raw_ostream &OS);
  75. void EmitCTags(RecordKeeper &RK, raw_ostream &OS);
  76. void EmitAttributes(RecordKeeper &RK, raw_ostream &OS);
  77. void EmitSearchableTables(RecordKeeper &RK, raw_ostream &OS);
  78. void EmitGlobalISel(RecordKeeper &RK, raw_ostream &OS);
  79. void EmitGICombiner(RecordKeeper &RK, raw_ostream &OS);
  80. void EmitX86EVEX2VEXTables(RecordKeeper &RK, raw_ostream &OS);
  81. void EmitX86FoldTables(RecordKeeper &RK, raw_ostream &OS);
  82. void EmitRegisterBank(RecordKeeper &RK, raw_ostream &OS);
  83. void EmitExegesis(RecordKeeper &RK, raw_ostream &OS);
  84. void EmitAutomata(RecordKeeper &RK, raw_ostream &OS);
  85. void EmitDirectivesDecl(RecordKeeper &RK, raw_ostream &OS);
  86. void EmitDirectivesImpl(RecordKeeper &RK, raw_ostream &OS);
  87. void EmitDirectivesGen(RecordKeeper &RK, raw_ostream &OS);
  88. } // End llvm namespace
  89. #endif