blob: 24bbf58b91ec93552636c265da9aeeaab66b6f2a [file] [log] [blame]
Bill Wendlingd64cd2b2009-05-15 01:12:28 +00001//===-- DwarfException.h - Dwarf Exception Framework -----------*- C++ -*--===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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 Wendlingd64cd2b2009-05-15 01:12:28 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file contains support for writing dwarf exception info into asm files.
10//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
14#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFEXCEPTION_H
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000015
Saleem Abdulrasool8076cab2014-06-11 01:19:03 +000016#include "EHStreamer.h"
Rafael Espindolafdc3e6f2011-05-10 18:39:09 +000017#include "llvm/CodeGen/AsmPrinter.h"
Amaury Sechet7067ad32016-02-26 20:30:37 +000018#include "llvm/MC/MCDwarf.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
Benjamin Kramer286d4662015-07-01 16:18:16 +000024class LLVM_LIBRARY_VISIBILITY DwarfCFIExceptionBase : public EHStreamer {
Rafael Espindolaa6001792015-03-09 18:29:12 +000025protected:
26 DwarfCFIExceptionBase(AsmPrinter *A);
27
28 /// Per-function flag to indicate if frame CFI info should be emitted.
29 bool shouldEmitCFI;
Joerg Sonnenberger7b837322017-01-02 18:05:27 +000030 /// Per-module flag to indicate if .cfi_section has beeen emitted.
31 bool hasEmittedCFISections;
Rafael Espindolaa6001792015-03-09 18:29:12 +000032
33 void markFunctionEnd() override;
Amaury Sechet7067ad32016-02-26 20:30:37 +000034 void endFragment() override;
Rafael Espindolaa6001792015-03-09 18:29:12 +000035};
36
Benjamin Kramer286d4662015-07-01 16:18:16 +000037class LLVM_LIBRARY_VISIBILITY DwarfCFIException : public DwarfCFIExceptionBase {
Rafael Espindolaef142e42015-03-09 18:11:42 +000038 /// Per-function flag to indicate if .cfi_personality should be emitted.
Rafael Espindola697edc82011-04-29 14:48:51 +000039 bool shouldEmitPersonality;
40
Amaury Sechet7067ad32016-02-26 20:30:37 +000041 /// Per-function flag to indicate if .cfi_personality must be emitted.
42 bool forceEmitPersonality;
43
Rafael Espindolaef142e42015-03-09 18:11:42 +000044 /// Per-function flag to indicate if .cfi_lsda should be emitted.
Rafael Espindola697edc82011-04-29 14:48:51 +000045 bool shouldEmitLSDA;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000046
Rafael Espindolaef142e42015-03-09 18:11:42 +000047 /// Per-function flag to indicate if frame moves info should be emitted.
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000048 bool shouldEmitMoves;
49
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000050public:
51 //===--------------------------------------------------------------------===//
52 // Main entry points.
53 //
54 DwarfCFIException(AsmPrinter *A);
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000055 ~DwarfCFIException() override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000056
Rafael Espindolaef142e42015-03-09 18:11:42 +000057 /// Emit all exception information that should come after the content.
Craig Topper7b883b32014-03-08 06:31:39 +000058 void endModule() override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000059
Rafael Espindolaef142e42015-03-09 18:11:42 +000060 /// Gather pre-function exception information. Assumes being emitted
61 /// immediately after the function entry point.
Craig Topper7b883b32014-03-08 06:31:39 +000062 void beginFunction(const MachineFunction *MF) override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000063
Rafael Espindolaef142e42015-03-09 18:11:42 +000064 /// Gather and emit post-function exception information.
Craig Topper7b883b32014-03-08 06:31:39 +000065 void endFunction(const MachineFunction *) override;
Amaury Sechet7067ad32016-02-26 20:30:37 +000066
67 void beginFragment(const MachineBasicBlock *MBB,
68 ExceptionSymbolProvider ESP) override;
Anton Korobeynikovb46ef572011-01-14 21:57:53 +000069};
70
Benjamin Kramer286d4662015-07-01 16:18:16 +000071class LLVM_LIBRARY_VISIBILITY ARMException : public DwarfCFIExceptionBase {
Rafael Espindolad09b4162018-02-09 17:00:25 +000072 void emitTypeInfos(unsigned TTypeEncoding, MCSymbol *TTBaseLabel) override;
Rafael Espindolaa17151a2013-10-08 13:08:17 +000073 ARMTargetStreamer &getTargetStreamer();
74
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000075public:
76 //===--------------------------------------------------------------------===//
77 // Main entry points.
78 //
79 ARMException(AsmPrinter *A);
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000080 ~ARMException() override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000081
Rafael Espindolaef142e42015-03-09 18:11:42 +000082 /// Emit all exception information that should come after the content.
Joerg Sonnenberger7b837322017-01-02 18:05:27 +000083 void endModule() override {}
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000084
Rafael Espindolaef142e42015-03-09 18:11:42 +000085 /// Gather pre-function exception information. Assumes being emitted
86 /// immediately after the function entry point.
Craig Topper7b883b32014-03-08 06:31:39 +000087 void beginFunction(const MachineFunction *MF) override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000088
Rafael Espindolaef142e42015-03-09 18:11:42 +000089 /// Gather and emit post-function exception information.
Craig Topper7b883b32014-03-08 06:31:39 +000090 void endFunction(const MachineFunction *) override;
Anton Korobeynikova7ec2dc2011-03-05 18:43:15 +000091};
Bill Wendlingd64cd2b2009-05-15 01:12:28 +000092} // End of namespace llvm
93
94#endif