blob: a4fd36f0339a2ed3e2af9dbeee3d59f57e471c10 [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"
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000019
20namespace llvm {
Chris Lattnerda790ea2010-04-05 05:28:23 +000021class MachineFunction;
Rafael Espindolaa17151a2013-10-08 13:08:17 +000022class ARMTargetStreamer;
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000023
Rafael Espindolaa6001792015-03-09 18:29:12 +000024class DwarfCFIExceptionBase : public EHStreamer {
25protected:
26 DwarfCFIExceptionBase(AsmPrinter *A);
27
28 /// Per-function flag to indicate if frame CFI info should be emitted.
29 bool shouldEmitCFI;
30
31 void markFunctionEnd() override;
32};
33
34class DwarfCFIException : public DwarfCFIExceptionBase {
Rafael Espindolaef142e42015-03-09 18:11:42 +000035 /// Per-function flag to indicate if .cfi_personality should be emitted.
Rafael Espindola697edc82011-04-29 14:48:51 +000036 bool shouldEmitPersonality;
37
Rafael Espindolaef142e42015-03-09 18:11:42 +000038 /// Per-function flag to indicate if .cfi_lsda should be emitted.
Rafael Espindola697edc82011-04-29 14:48:51 +000039 bool shouldEmitLSDA;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000040
Rafael Espindolaef142e42015-03-09 18:11:42 +000041 /// Per-function flag to indicate if frame moves info should be emitted.
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000042 bool shouldEmitMoves;
43
Rafael Espindolafdc3e6f2011-05-10 18:39:09 +000044 AsmPrinter::CFIMoveType moveTypeModule;
45
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000046public:
47 //===--------------------------------------------------------------------===//
48 // Main entry points.
49 //
50 DwarfCFIException(AsmPrinter *A);
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000051 ~DwarfCFIException() override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000052
Rafael Espindolaef142e42015-03-09 18:11:42 +000053 /// Emit all exception information that should come after the content.
Craig Topper7b883b32014-03-08 06:31:39 +000054 void endModule() override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000055
Rafael Espindolaef142e42015-03-09 18:11:42 +000056 /// Gather pre-function exception information. Assumes being emitted
57 /// immediately after the function entry point.
Craig Topper7b883b32014-03-08 06:31:39 +000058 void beginFunction(const MachineFunction *MF) override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000059
Rafael Espindolaef142e42015-03-09 18:11:42 +000060 /// Gather and emit post-function exception information.
Craig Topper7b883b32014-03-08 06:31:39 +000061 void endFunction(const MachineFunction *) override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000062};
63
Rafael Espindolaa6001792015-03-09 18:29:12 +000064class ARMException : public DwarfCFIExceptionBase {
Saleem Abdulrasool8076cab2014-06-11 01:19:03 +000065 void emitTypeInfos(unsigned TTypeEncoding) override;
Rafael Espindolaa17151a2013-10-08 13:08:17 +000066 ARMTargetStreamer &getTargetStreamer();
67
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000068public:
69 //===--------------------------------------------------------------------===//
70 // Main entry points.
71 //
72 ARMException(AsmPrinter *A);
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000073 ~ARMException() override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000074
Rafael Espindolaef142e42015-03-09 18:11:42 +000075 /// Emit all exception information that should come after the content.
Craig Topper7b883b32014-03-08 06:31:39 +000076 void endModule() override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000077
Rafael Espindolaef142e42015-03-09 18:11:42 +000078 /// Gather pre-function exception information. Assumes being emitted
79 /// immediately after the function entry point.
Craig Topper7b883b32014-03-08 06:31:39 +000080 void beginFunction(const MachineFunction *MF) override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000081
Rafael Espindolaef142e42015-03-09 18:11:42 +000082 /// Gather and emit post-function exception information.
Craig Topper7b883b32014-03-08 06:31:39 +000083 void endFunction(const MachineFunction *) override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000084};
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000085} // End of namespace llvm
86
87#endif