xref: /freebsd/contrib/llvm-project/llvm/include/llvm/CodeGen/AsmPrinterHandler.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===-- 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/Compiler.h"
18 #include "llvm/Support/DataTypes.h"
19 
20 namespace llvm {
21 
22 class AsmPrinter;
23 class MachineBasicBlock;
24 class MachineFunction;
25 class MachineInstr;
26 class MCSymbol;
27 class Module;
28 
29 typedef MCSymbol *ExceptionSymbolProvider(AsmPrinter *Asm,
30                                           const MachineBasicBlock *MBB);
31 
32 /// Collects and handles AsmPrinter objects required to build debug
33 /// or EH information.
34 class LLVM_ABI AsmPrinterHandler {
35 public:
36   virtual ~AsmPrinterHandler();
37 
beginModule(Module * M)38   virtual void beginModule(Module *M) {}
39 
40   /// Emit all sections that should come after the content.
41   virtual void endModule() = 0;
42 
43   /// Gather pre-function debug information.
44   /// Every beginFunction(MF) call should be followed by an endFunction(MF)
45   /// call.
46   virtual void beginFunction(const MachineFunction *MF) = 0;
47 
48   // Emit any of function marker (like .cfi_endproc). This is called
49   // before endFunction and cannot switch sections.
50   virtual void markFunctionEnd();
51 
52   /// Gather post-function debug information.
53   virtual void endFunction(const MachineFunction *MF) = 0;
54 
55   /// Process the beginning of a new basic-block-section within a
56   /// function. Always called immediately after beginFunction for the first
57   /// basic-block. When basic-block-sections are enabled, called before the
58   /// first block of each such section.
beginBasicBlockSection(const MachineBasicBlock & MBB)59   virtual void beginBasicBlockSection(const MachineBasicBlock &MBB) {}
60 
61   /// Process the end of a basic-block-section within a function. When
62   /// basic-block-sections are enabled, called after the last block in each such
63   /// section (including the last section in the function). When
64   /// basic-block-sections are disabled, called at the end of a function,
65   /// immediately prior to markFunctionEnd.
endBasicBlockSection(const MachineBasicBlock & MBB)66   virtual void endBasicBlockSection(const MachineBasicBlock &MBB) {}
67 
68   /// For symbols that have a size designated (e.g. common symbols),
69   /// this tracks that size.
setSymbolSize(const MCSymbol * Sym,uint64_t Size)70   virtual void setSymbolSize(const MCSymbol *Sym, uint64_t Size) {}
71 
72   /// Process beginning of an instruction.
beginInstruction(const MachineInstr * MI)73   virtual void beginInstruction(const MachineInstr *MI) {}
74 
75   /// Process end of an instruction.
endInstruction()76   virtual void endInstruction() {}
77 
beginCodeAlignment(const MachineBasicBlock & MBB)78   virtual void beginCodeAlignment(const MachineBasicBlock &MBB) {}
79 
80   /// Emit target-specific EH funclet machinery.
81   virtual void beginFunclet(const MachineBasicBlock &MBB,
82                             MCSymbol *Sym = nullptr) {}
endFunclet()83   virtual void endFunclet() {}
84 };
85 
86 } // End of namespace llvm
87 
88 #endif
89