1 //===-- lib/CodeGen/AsmPrinter/AsmPrinterHandler.h -------------*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains a generic interface for AsmPrinter handlers,
11 // like debug and EH info emitters.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ASMPRINTERHANDLER_H
16 #define LLVM_LIB_CODEGEN_ASMPRINTER_ASMPRINTERHANDLER_H
18 #include "llvm/Support/DataTypes.h"
23 class MachineBasicBlock;
24 class MachineFunction;
28 typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm);
30 /// Collects and handles AsmPrinter objects required to build debug
31 /// or EH information.
32 class AsmPrinterHandler {
34 virtual ~AsmPrinterHandler();
36 /// For symbols that have a size designated (e.g. common symbols),
37 /// this tracks that size.
38 virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) = 0;
40 /// Emit all sections that should come after the content.
41 virtual void endModule() = 0;
43 /// Gather pre-function debug information.
44 /// Every beginFunction(MF) call should be followed by an endFunction(MF)
46 virtual void beginFunction(const MachineFunction *MF) = 0;
48 // Emit any of function marker (like .cfi_endproc). This is called
49 // before endFunction and cannot switch sections.
50 virtual void markFunctionEnd();
52 /// Gather post-function debug information.
53 /// Please note that some AsmPrinter implementations may not call
54 /// beginFunction at all.
55 virtual void endFunction(const MachineFunction *MF) = 0;
57 virtual void beginFragment(const MachineBasicBlock *MBB,
58 ExceptionSymbolProvider ESP) {}
59 virtual void endFragment() {}
61 /// Emit target-specific EH funclet machinery.
62 virtual void beginFunclet(const MachineBasicBlock &MBB,
63 MCSymbol *Sym = nullptr) {}
64 virtual void endFunclet() {}
66 /// Process beginning of an instruction.
67 virtual void beginInstruction(const MachineInstr *MI) = 0;
69 /// Process end of an instruction.
70 virtual void endInstruction() = 0;
72 } // End of namespace llvm