blob: affb558f2fa66f632b66d90d47243a6d35aa2d33 [file] [log] [blame]
Andrew Walbran16937d02019-10-22 13:54:20 +01001//===-- llvm/CodeGen/AsmPrinterHandler.h -----------------------*- 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 file contains a generic interface for AsmPrinter handlers,
10// like debug and EH info emitters.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_ASMPRINTERHANDLER_H
15#define LLVM_CODEGEN_ASMPRINTERHANDLER_H
16
17#include "llvm/Support/DataTypes.h"
18
19namespace llvm {
20
21class AsmPrinter;
22class MachineBasicBlock;
23class MachineFunction;
24class MachineInstr;
25class MCSymbol;
26
27typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm);
28
29/// Collects and handles AsmPrinter objects required to build debug
30/// or EH information.
31class AsmPrinterHandler {
32public:
33 virtual ~AsmPrinterHandler();
34
35 /// For symbols that have a size designated (e.g. common symbols),
36 /// this tracks that size.
37 virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) = 0;
38
39 /// Emit all sections that should come after the content.
40 virtual void endModule() = 0;
41
42 /// Gather pre-function debug information.
43 /// Every beginFunction(MF) call should be followed by an endFunction(MF)
44 /// call.
45 virtual void beginFunction(const MachineFunction *MF) = 0;
46
47 // Emit any of function marker (like .cfi_endproc). This is called
48 // before endFunction and cannot switch sections.
49 virtual void markFunctionEnd();
50
51 /// Gather post-function debug information.
52 /// Please note that some AsmPrinter implementations may not call
53 /// beginFunction at all.
54 virtual void endFunction(const MachineFunction *MF) = 0;
55
56 virtual void beginFragment(const MachineBasicBlock *MBB,
57 ExceptionSymbolProvider ESP) {}
58 virtual void endFragment() {}
59
60 /// Emit target-specific EH funclet machinery.
61 virtual void beginFunclet(const MachineBasicBlock &MBB,
62 MCSymbol *Sym = nullptr) {}
63 virtual void endFunclet() {}
64
65 /// Process beginning of an instruction.
66 virtual void beginInstruction(const MachineInstr *MI) = 0;
67
68 /// Process end of an instruction.
69 virtual void endInstruction() = 0;
70};
71} // End of namespace llvm
72
73#endif