1 //===-- DwarfException.h - Dwarf Exception Framework -----------*- 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 support for writing dwarf exception info into asm files. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H 14 #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H 15 16 #include "EHStreamer.h" 17 #include "llvm/CodeGen/AsmPrinter.h" 18 #include "llvm/MC/MCDwarf.h" 19 20 namespace llvm { 21 class MachineFunction; 22 class ARMTargetStreamer; 23 24 class LLVM_LIBRARY_VISIBILITY DwarfCFIExceptionBase : public EHStreamer { 25 protected: 26 DwarfCFIExceptionBase(AsmPrinter *A); 27 28 /// Per-function flag to indicate if frame CFI info should be emitted. 29 bool shouldEmitCFI; 30 /// Per-module flag to indicate if .cfi_section has beeen emitted. 31 bool hasEmittedCFISections; 32 33 void markFunctionEnd() override; 34 void endFragment() override; 35 }; 36 37 class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase { 38 /// Per-function flag to indicate if .cfi_personality should be emitted. 39 bool shouldEmitPersonality; 40 41 /// Per-function flag to indicate if .cfi_personality must be emitted. 42 bool forceEmitPersonality; 43 44 /// Per-function flag to indicate if .cfi_lsda should be emitted. 45 bool shouldEmitLSDA; 46 47 /// Per-function flag to indicate if frame moves info should be emitted. 48 bool shouldEmitMoves; 49 50 public: 51 //===--------------------------------------------------------------------===// 52 // Main entry points. 53 // 54 DwarfCFIException(AsmPrinter *A); 55 ~DwarfCFIException() override; 56 57 /// Emit all exception information that should come after the content. 58 void endModule() override; 59 60 /// Gather pre-function exception information. Assumes being emitted 61 /// immediately after the function entry point. 62 void beginFunction(const MachineFunction *MF) override; 63 64 /// Gather and emit post-function exception information. 65 void endFunction(const MachineFunction *) override; 66 67 void beginFragment(const MachineBasicBlock *MBB, 68 ExceptionSymbolProvider ESP) override; 69 70 void beginBasicBlock(const MachineBasicBlock &MBB) override; 71 void endBasicBlock(const MachineBasicBlock &MBB) override; 72 }; 73 74 class LLVM_LIBRARY_VISIBILITY ARMException : public DwarfCFIExceptionBase { 75 void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel) override; 76 ARMTargetStreamer &getTargetStreamer(); 77 78 public: 79 //===--------------------------------------------------------------------===// 80 // Main entry points. 81 // 82 ARMException(AsmPrinter *A); 83 ~ARMException() override; 84 85 /// Emit all exception information that should come after the content. 86 void endModule() override {} 87 88 /// Gather pre-function exception information. Assumes being emitted 89 /// immediately after the function entry point. 90 void beginFunction(const MachineFunction *MF) override; 91 92 /// Gather and emit post-function exception information. 93 void endFunction(const MachineFunction *) override; 94 }; 95 } // End of namespace llvm 96 97 #endif 98