blob: dc81a304009772fe2cbafa301e92a11e6648b21d [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;
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020026class Module;
Andrew Walbran16937d02019-10-22 13:54:20 +010027
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020028typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm,
29 const MachineBasicBlock *MBB);
Andrew Walbran16937d02019-10-22 13:54:20 +010030
31/// Collects and handles AsmPrinter objects required to build debug
32/// or EH information.
33class AsmPrinterHandler {
34public:
35 virtual ~AsmPrinterHandler();
36
37 /// For symbols that have a size designated (e.g. common symbols),
38 /// this tracks that size.
39 virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) = 0;
40
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020041 virtual void beginModule(Module *M) {}
42
Andrew Walbran16937d02019-10-22 13:54:20 +010043 /// Emit all sections that should come after the content.
44 virtual void endModule() = 0;
45
46 /// Gather pre-function debug information.
47 /// Every beginFunction(MF) call should be followed by an endFunction(MF)
48 /// call.
49 virtual void beginFunction(const MachineFunction *MF) = 0;
50
51 // Emit any of function marker (like .cfi_endproc). This is called
52 // before endFunction and cannot switch sections.
53 virtual void markFunctionEnd();
54
55 /// Gather post-function debug information.
56 /// Please note that some AsmPrinter implementations may not call
57 /// beginFunction at all.
58 virtual void endFunction(const MachineFunction *MF) = 0;
59
60 virtual void beginFragment(const MachineBasicBlock *MBB,
61 ExceptionSymbolProvider ESP) {}
62 virtual void endFragment() {}
63
64 /// Emit target-specific EH funclet machinery.
65 virtual void beginFunclet(const MachineBasicBlock &MBB,
66 MCSymbol *Sym = nullptr) {}
67 virtual void endFunclet() {}
68
69 /// Process beginning of an instruction.
70 virtual void beginInstruction(const MachineInstr *MI) = 0;
71
72 /// Process end of an instruction.
73 virtual void endInstruction() = 0;
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020074
75 /// Process beginning of a basic block during basic block sections.
76 virtual void beginBasicBlock(const MachineBasicBlock &MBB) {}
77
78 /// Process end of a basic block during basic block sections.
79 virtual void endBasicBlock(const MachineBasicBlock &MBB) {}
Andrew Walbran16937d02019-10-22 13:54:20 +010080};
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020081
Andrew Walbran16937d02019-10-22 13:54:20 +010082} // End of namespace llvm
83
84#endif