xref: /freebsd/contrib/llvm-project/llvm/include/llvm/DWARFCFIChecker/DWARFCFIFunctionFrameReceiver.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===----------------------------------------------------------------------===//
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 /// \file
10 /// This file declares CFIFunctionFrameReceiver class.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_DWARFCFICHECKER_DWARFCFIFUNCTIONFRAMERECEIVER_H
15 #define LLVM_DWARFCFICHECKER_DWARFCFIFUNCTIONFRAMERECEIVER_H
16 
17 #include "llvm/ADT/ArrayRef.h"
18 
19 namespace llvm {
20 
21 class MCCFIInstruction;
22 class MCContext;
23 class MCInst;
24 
25 /// This abstract base class is an interface for receiving DWARF function frames
26 /// Call Frame Information. `DWARFCFIFunctionFrameStreamer` channels the
27 /// function frames information gathered from an `MCStreamer` using a pointer to
28 /// an instance of this class for the whole program.
29 class CFIFunctionFrameReceiver {
30 public:
31   CFIFunctionFrameReceiver(const CFIFunctionFrameReceiver &) = delete;
32   CFIFunctionFrameReceiver &
33   operator=(const CFIFunctionFrameReceiver &) = delete;
34   virtual ~CFIFunctionFrameReceiver() = default;
35 
CFIFunctionFrameReceiver(MCContext & Context)36   CFIFunctionFrameReceiver(MCContext &Context) : Context(Context) {}
37 
getContext()38   MCContext &getContext() const { return Context; }
39 
startFunctionFrame(bool IsEH,ArrayRef<MCCFIInstruction> Prologue)40   virtual void startFunctionFrame(bool IsEH,
41                                   ArrayRef<MCCFIInstruction> Prologue) {}
42   /// Instructions are processed in the program order.
43   virtual void
emitInstructionAndDirectives(const MCInst & Inst,ArrayRef<MCCFIInstruction> Directives)44   emitInstructionAndDirectives(const MCInst &Inst,
45                                ArrayRef<MCCFIInstruction> Directives) {}
finishFunctionFrame()46   virtual void finishFunctionFrame() {}
47 
48 private:
49   MCContext &Context;
50 };
51 
52 } // namespace llvm
53 
54 #endif
55