blob: 80d5bd208ed8dbff171f53ab01ab24a67c6965c9 [file] [log] [blame]
Bill Wendlingd64cd2b2009-05-15 01:12:28 +00001//===-- 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 Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
15#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000016
Saleem Abdulrasool8076cab2014-06-11 01:19:03 +000017#include "EHStreamer.h"
Rafael Espindolafdc3e6f2011-05-10 18:39:09 +000018#include "llvm/CodeGen/AsmPrinter.h"
Amaury Sechet7067ad32016-02-26 20:30:37 +000019#include "llvm/MC/MCDwarf.h"
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000020
21namespace llvm {
Chris Lattnerda790ea2010-04-05 05:28:23 +000022class MachineFunction;
Rafael Espindolaa17151a2013-10-08 13:08:17 +000023class ARMTargetStreamer;
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000024
Benjamin Kramer286d4662015-07-01 16:18:16 +000025class LLVM_LIBRARY_VISIBILITY DwarfCFIExceptionBase : public EHStreamer {
Rafael Espindolaa6001792015-03-09 18:29:12 +000026protected:
27 DwarfCFIExceptionBase(AsmPrinter *A);
28
29 /// Per-function flag to indicate if frame CFI info should be emitted.
30 bool shouldEmitCFI;
Joerg Sonnenberger7b837322017-01-02 18:05:27 +000031 /// Per-module flag to indicate if .cfi_section has beeen emitted.
32 bool hasEmittedCFISections;
Rafael Espindolaa6001792015-03-09 18:29:12 +000033
34 void markFunctionEnd() override;
Amaury Sechet7067ad32016-02-26 20:30:37 +000035 void endFragment() override;
Rafael Espindolaa6001792015-03-09 18:29:12 +000036};
37
Benjamin Kramer286d4662015-07-01 16:18:16 +000038class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase {
Rafael Espindolaef142e42015-03-09 18:11:42 +000039 /// Per-function flag to indicate if .cfi_personality should be emitted.
Rafael Espindola697edc82011-04-29 14:48:51 +000040 bool shouldEmitPersonality;
41
Amaury Sechet7067ad32016-02-26 20:30:37 +000042 /// Per-function flag to indicate if .cfi_personality must be emitted.
43 bool forceEmitPersonality;
44
Rafael Espindolaef142e42015-03-09 18:11:42 +000045 /// Per-function flag to indicate if .cfi_lsda should be emitted.
Rafael Espindola697edc82011-04-29 14:48:51 +000046 bool shouldEmitLSDA;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000047
Rafael Espindolaef142e42015-03-09 18:11:42 +000048 /// Per-function flag to indicate if frame moves info should be emitted.
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000049 bool shouldEmitMoves;
50
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000051public:
52 //===--------------------------------------------------------------------===//
53 // Main entry points.
54 //
55 DwarfCFIException(AsmPrinter *A);
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000056 ~DwarfCFIException() override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000057
Rafael Espindolaef142e42015-03-09 18:11:42 +000058 /// Emit all exception information that should come after the content.
Craig Topper7b883b32014-03-08 06:31:39 +000059 void endModule() override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000060
Rafael Espindolaef142e42015-03-09 18:11:42 +000061 /// Gather pre-function exception information. Assumes being emitted
62 /// immediately after the function entry point.
Craig Topper7b883b32014-03-08 06:31:39 +000063 void beginFunction(const MachineFunction *MF) override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000064
Rafael Espindolaef142e42015-03-09 18:11:42 +000065 /// Gather and emit post-function exception information.
Craig Topper7b883b32014-03-08 06:31:39 +000066 void endFunction(const MachineFunction *) override;
Amaury Sechet7067ad32016-02-26 20:30:37 +000067
68 void beginFragment(const MachineBasicBlock *MBB,
69 ExceptionSymbolProvider ESP) override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000070};
71
Benjamin Kramer286d4662015-07-01 16:18:16 +000072class LLVM_LIBRARY_VISIBILITY ARMException : public DwarfCFIExceptionBase {
Saleem Abdulrasool8076cab2014-06-11 01:19:03 +000073 void emitTypeInfos(unsigned TTypeEncoding) override;
Rafael Espindolaa17151a2013-10-08 13:08:17 +000074 ARMTargetStreamer &getTargetStreamer();
75
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000076public:
77 //===--------------------------------------------------------------------===//
78 // Main entry points.
79 //
80 ARMException(AsmPrinter *A);
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000081 ~ARMException() override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000082
Rafael Espindolaef142e42015-03-09 18:11:42 +000083 /// Emit all exception information that should come after the content.
Joerg Sonnenberger7b837322017-01-02 18:05:27 +000084 void endModule() override {}
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000085
Rafael Espindolaef142e42015-03-09 18:11:42 +000086 /// Gather pre-function exception information. Assumes being emitted
87 /// immediately after the function entry point.
Craig Topper7b883b32014-03-08 06:31:39 +000088 void beginFunction(const MachineFunction *MF) override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000089
Rafael Espindolaef142e42015-03-09 18:11:42 +000090 /// Gather and emit post-function exception information.
Craig Topper7b883b32014-03-08 06:31:39 +000091 void endFunction(const MachineFunction *) override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000092};
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000093} // End of namespace llvm
94
95#endif