blob: 638226e90a7a6cced2aad5ede2712ac026f99465 [file] [log] [blame]
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +00001//===-- lib/CodeGen/AsmPrinter/AsmPrinterHandler.h -------------*- 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// This file contains a generic interface for AsmPrinter handlers,
11// like debug and EH info emitters.
12//
13//===----------------------------------------------------------------------===//
14
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_ASMPRINTERHANDLER_H
16#define LLVM_LIB_CODEGEN_ASMPRINTER_ASMPRINTERHANDLER_H
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000017
18#include "llvm/Support/DataTypes.h"
19
20namespace llvm {
21
Amaury Sechet7067ad32016-02-26 20:30:37 +000022class AsmPrinter;
David Majnemera80c1512015-09-29 20:12:33 +000023class MachineBasicBlock;
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000024class MachineFunction;
25class MachineInstr;
26class MCSymbol;
27
Amaury Sechet7067ad32016-02-26 20:30:37 +000028typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm);
29
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000030/// \brief Collects and handles AsmPrinter objects required to build debug
31/// or EH information.
32class AsmPrinterHandler {
33public:
Juergen Ributzkadb9ee002013-12-14 12:23:14 +000034 virtual ~AsmPrinterHandler();
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000035
36 /// \brief 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;
39
40 /// \brief Emit all sections that should come after the content.
41 virtual void endModule() = 0;
42
43 /// \brief Gather pre-function debug information.
Eric Christopher4df11602013-12-10 00:26:06 +000044 /// Every beginFunction(MF) call should be followed by an endFunction(MF)
45 /// call.
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000046 virtual void beginFunction(const MachineFunction *MF) = 0;
47
Rafael Espindolaa6001792015-03-09 18:29:12 +000048 // \brief Emit any of function marker (like .cfi_endproc). This is called
49 // before endFunction and cannot switch sections.
50 virtual void markFunctionEnd();
51
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000052 /// \brief Gather post-function debug information.
Timur Iskhodzhanovc05ef042013-12-03 18:57:43 +000053 /// Please note that some AsmPrinter implementations may not call
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000054 /// beginFunction at all.
55 virtual void endFunction(const MachineFunction *MF) = 0;
56
Amaury Sechet7067ad32016-02-26 20:30:37 +000057 virtual void beginFragment(const MachineBasicBlock *MBB,
58 ExceptionSymbolProvider ESP) {}
59 virtual void endFragment() {}
60
David Majnemera80c1512015-09-29 20:12:33 +000061 /// \brief Emit target-specific EH funclet machinery.
62 virtual void beginFunclet(const MachineBasicBlock &MBB,
63 MCSymbol *Sym = nullptr) {}
64 virtual void endFunclet() {}
65
Timur Iskhodzhanov1cd14442013-12-03 15:10:23 +000066 /// \brief Process beginning of an instruction.
67 virtual void beginInstruction(const MachineInstr *MI) = 0;
68
69 /// \brief Process end of an instruction.
70 virtual void endInstruction() = 0;
71};
72} // End of namespace llvm
73
74#endif