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