Bill Wendling | d64cd2b | 2009-05-15 01:12:28 +0000 | [diff] [blame] | 1 | //===-- DwarfException.h - Dwarf Exception Framework -----------*- C++ -*--===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Bill Wendling | d64cd2b | 2009-05-15 01:12:28 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file contains support for writing dwarf exception info into asm files. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 13 | #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H |
| 14 | #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H |
Bill Wendling | d64cd2b | 2009-05-15 01:12:28 +0000 | [diff] [blame] | 15 | |
Saleem Abdulrasool | 8076cab | 2014-06-11 01:19:03 +0000 | [diff] [blame] | 16 | #include "EHStreamer.h" |
Rafael Espindola | fdc3e6f | 2011-05-10 18:39:09 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/AsmPrinter.h" |
Amaury Sechet | 7067ad3 | 2016-02-26 20:30:37 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCDwarf.h" |
Bill Wendling | d64cd2b | 2009-05-15 01:12:28 +0000 | [diff] [blame] | 19 | |
| 20 | namespace llvm { |
Chris Lattner | da790ea | 2010-04-05 05:28:23 +0000 | [diff] [blame] | 21 | class MachineFunction; |
Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 22 | class ARMTargetStreamer; |
Bill Wendling | d64cd2b | 2009-05-15 01:12:28 +0000 | [diff] [blame] | 23 | |
Benjamin Kramer | 286d466 | 2015-07-01 16:18:16 +0000 | [diff] [blame] | 24 | class LLVM_LIBRARY_VISIBILITY DwarfCFIExceptionBase : public EHStreamer { |
Rafael Espindola | a600179 | 2015-03-09 18:29:12 +0000 | [diff] [blame] | 25 | protected: |
| 26 | DwarfCFIExceptionBase(AsmPrinter *A); |
| 27 | |
| 28 | /// Per-function flag to indicate if frame CFI info should be emitted. |
| 29 | bool shouldEmitCFI; |
Joerg Sonnenberger | 7b83732 | 2017-01-02 18:05:27 +0000 | [diff] [blame] | 30 | /// Per-module flag to indicate if .cfi_section has beeen emitted. |
| 31 | bool hasEmittedCFISections; |
Rafael Espindola | a600179 | 2015-03-09 18:29:12 +0000 | [diff] [blame] | 32 | |
| 33 | void markFunctionEnd() override; |
Amaury Sechet | 7067ad3 | 2016-02-26 20:30:37 +0000 | [diff] [blame] | 34 | void endFragment() override; |
Rafael Espindola | a600179 | 2015-03-09 18:29:12 +0000 | [diff] [blame] | 35 | }; |
| 36 | |
Benjamin Kramer | 286d466 | 2015-07-01 16:18:16 +0000 | [diff] [blame] | 37 | class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase { |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 38 | /// Per-function flag to indicate if .cfi_personality should be emitted. |
Rafael Espindola | 697edc8 | 2011-04-29 14:48:51 +0000 | [diff] [blame] | 39 | bool shouldEmitPersonality; |
| 40 | |
Amaury Sechet | 7067ad3 | 2016-02-26 20:30:37 +0000 | [diff] [blame] | 41 | /// Per-function flag to indicate if .cfi_personality must be emitted. |
| 42 | bool forceEmitPersonality; |
| 43 | |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 44 | /// Per-function flag to indicate if .cfi_lsda should be emitted. |
Rafael Espindola | 697edc8 | 2011-04-29 14:48:51 +0000 | [diff] [blame] | 45 | bool shouldEmitLSDA; |
Anton Korobeynikov | b46ef57 | 2011-01-14 21:57:53 +0000 | [diff] [blame] | 46 | |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 47 | /// Per-function flag to indicate if frame moves info should be emitted. |
Anton Korobeynikov | b46ef57 | 2011-01-14 21:57:53 +0000 | [diff] [blame] | 48 | bool shouldEmitMoves; |
| 49 | |
Anton Korobeynikov | b46ef57 | 2011-01-14 21:57:53 +0000 | [diff] [blame] | 50 | public: |
| 51 | //===--------------------------------------------------------------------===// |
| 52 | // Main entry points. |
| 53 | // |
| 54 | DwarfCFIException(AsmPrinter *A); |
Alexander Kornienko | f817c1c | 2015-04-11 02:11:45 +0000 | [diff] [blame] | 55 | ~DwarfCFIException() override; |
Anton Korobeynikov | b46ef57 | 2011-01-14 21:57:53 +0000 | [diff] [blame] | 56 | |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 57 | /// Emit all exception information that should come after the content. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 58 | void endModule() override; |
Anton Korobeynikov | b46ef57 | 2011-01-14 21:57:53 +0000 | [diff] [blame] | 59 | |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 60 | /// Gather pre-function exception information. Assumes being emitted |
| 61 | /// immediately after the function entry point. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 62 | void beginFunction(const MachineFunction *MF) override; |
Anton Korobeynikov | b46ef57 | 2011-01-14 21:57:53 +0000 | [diff] [blame] | 63 | |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 64 | /// Gather and emit post-function exception information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 65 | void endFunction(const MachineFunction *) override; |
Amaury Sechet | 7067ad3 | 2016-02-26 20:30:37 +0000 | [diff] [blame] | 66 | |
| 67 | void beginFragment(const MachineBasicBlock *MBB, |
| 68 | ExceptionSymbolProvider ESP) override; |
Anton Korobeynikov | b46ef57 | 2011-01-14 21:57:53 +0000 | [diff] [blame] | 69 | }; |
| 70 | |
Benjamin Kramer | 286d466 | 2015-07-01 16:18:16 +0000 | [diff] [blame] | 71 | class LLVM_LIBRARY_VISIBILITY ARMException : public DwarfCFIExceptionBase { |
Rafael Espindola | d09b416 | 2018-02-09 17:00:25 +0000 | [diff] [blame] | 72 | void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel) override; |
Rafael Espindola | a17151a | 2013-10-08 13:08:17 +0000 | [diff] [blame] | 73 | ARMTargetStreamer &getTargetStreamer(); |
| 74 | |
Anton Korobeynikov | a7ec2dc | 2011-03-05 18:43:15 +0000 | [diff] [blame] | 75 | public: |
| 76 | //===--------------------------------------------------------------------===// |
| 77 | // Main entry points. |
| 78 | // |
| 79 | ARMException(AsmPrinter *A); |
Alexander Kornienko | f817c1c | 2015-04-11 02:11:45 +0000 | [diff] [blame] | 80 | ~ARMException() override; |
Anton Korobeynikov | a7ec2dc | 2011-03-05 18:43:15 +0000 | [diff] [blame] | 81 | |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 82 | /// Emit all exception information that should come after the content. |
Joerg Sonnenberger | 7b83732 | 2017-01-02 18:05:27 +0000 | [diff] [blame] | 83 | void endModule() override {} |
Anton Korobeynikov | a7ec2dc | 2011-03-05 18:43:15 +0000 | [diff] [blame] | 84 | |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 85 | /// Gather pre-function exception information. Assumes being emitted |
| 86 | /// immediately after the function entry point. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 87 | void beginFunction(const MachineFunction *MF) override; |
Anton Korobeynikov | a7ec2dc | 2011-03-05 18:43:15 +0000 | [diff] [blame] | 88 | |
Rafael Espindola | ef142e4 | 2015-03-09 18:11:42 +0000 | [diff] [blame] | 89 | /// Gather and emit post-function exception information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 90 | void endFunction(const MachineFunction *) override; |
Anton Korobeynikov | a7ec2dc | 2011-03-05 18:43:15 +0000 | [diff] [blame] | 91 | }; |
Bill Wendling | d64cd2b | 2009-05-15 01:12:28 +0000 | [diff] [blame] | 92 | } // End of namespace llvm |
| 93 | |
| 94 | #endif |