TableGenBackendSkeleton.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //===- SkeletonEmitter.cpp - Skeleton TableGen backend -*- C++ -*-===//
  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 Tablegen backend emits ...
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #include "llvm/ADT/ArrayRef.h"
  13. #include "llvm/ADT/DenseMap.h"
  14. #include "llvm/ADT/StringExtras.h"
  15. #include "llvm/Support/Format.h"
  16. #include "llvm/Support/MemoryBuffer.h"
  17. #include "llvm/Support/SourceMgr.h"
  18. #include "llvm/TableGen/Error.h"
  19. #include "llvm/TableGen/Record.h"
  20. #include "llvm/TableGen/TableGenBackend.h"
  21. #include <algorithm>
  22. #include <set>
  23. #include <string>
  24. #include <vector>
  25. #define DEBUG_TYPE "skeleton-emitter"
  26. using namespace llvm;
  27. namespace {
  28. // Any helper data structures can be defined here. Some backends use
  29. // structs to collect information from the records.
  30. class SkeletonEmitter {
  31. private:
  32. RecordKeeper &Records;
  33. public:
  34. SkeletonEmitter(RecordKeeper &RK) : Records(RK) {}
  35. void run(raw_ostream &OS);
  36. }; // emitter class
  37. } // anonymous namespace
  38. void SkeletonEmitter::run(raw_ostream &OS) {
  39. emitSourceFileHeader("Skeleton data structures", OS);
  40. (void)Records; // To suppress unused variable warning; remove on use.
  41. }
  42. namespace llvm {
  43. // The only thing that should be in the llvm namespace is the
  44. // emitter entry point function.
  45. void EmitSkeleton(RecordKeeper &RK, raw_ostream &OS) {
  46. // Instantiate the emitter class and invoke run().
  47. SkeletonEmitter(RK).run(OS);
  48. }
  49. } // namespace llvm