GCMetadataPrinter.h revision 344779
1//===- llvm/CodeGen/GCMetadataPrinter.h - Prints asm GC tables --*- C++ -*-===//
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// The abstract base class GCMetadataPrinter supports writing GC metadata tables
11// as assembly code. This is a separate class from GCStrategy in order to allow
12// users of the LLVM JIT to avoid linking with the AsmWriter.
13//
14// Subclasses of GCMetadataPrinter must be registered using the
15// GCMetadataPrinterRegistry. This is separate from the GCStrategy itself
16// because these subclasses are logically plugins for the AsmWriter.
17//
18//===----------------------------------------------------------------------===//
19
20#ifndef LLVM_CODEGEN_GCMETADATAPRINTER_H
21#define LLVM_CODEGEN_GCMETADATAPRINTER_H
22
23#include "llvm/Support/Registry.h"
24
25namespace llvm {
26
27class AsmPrinter;
28class GCMetadataPrinter;
29class GCModuleInfo;
30class GCStrategy;
31class Module;
32class StackMaps;
33
34/// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
35/// defaults from Registry.
36using GCMetadataPrinterRegistry = Registry<GCMetadataPrinter>;
37
38/// GCMetadataPrinter - Emits GC metadata as assembly code.  Instances are
39/// created, managed, and owned by the AsmPrinter.
40class GCMetadataPrinter {
41private:
42  friend class AsmPrinter;
43
44  GCStrategy *S;
45
46protected:
47  // May only be subclassed.
48  GCMetadataPrinter();
49
50public:
51  GCMetadataPrinter(const GCMetadataPrinter &) = delete;
52  GCMetadataPrinter &operator=(const GCMetadataPrinter &) = delete;
53  virtual ~GCMetadataPrinter();
54
55  GCStrategy &getStrategy() { return *S; }
56
57  /// Called before the assembly for the module is generated by
58  /// the AsmPrinter (but after target specific hooks.)
59  virtual void beginAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
60
61  /// Called after the assembly for the module is generated by
62  /// the AsmPrinter (but before target specific hooks)
63  virtual void finishAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
64
65  /// Called when the stack maps are generated. Return true if
66  /// stack maps with a custom format are generated. Otherwise
67  /// returns false and the default format will be used.
68  virtual bool emitStackMaps(StackMaps &SM, AsmPrinter &AP) { return false; }
69};
70
71} // end namespace llvm
72
73#endif // LLVM_CODEGEN_GCMETADATAPRINTER_H
74