blob: 3f2387325360032896473cd2810a31f171aea311 [file] [log] [blame]
Anton Korobeynikovb5e16af2011-03-05 18:43:15 +00001//===-- CodeGen/AsmPrinter/ARMException.cpp - ARM EHABI Exception Impl ----===//
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
14#include "DwarfException.h"
15#include "llvm/Module.h"
16#include "llvm/CodeGen/AsmPrinter.h"
17#include "llvm/CodeGen/MachineModuleInfo.h"
18#include "llvm/CodeGen/MachineFrameInfo.h"
19#include "llvm/CodeGen/MachineFunction.h"
Anton Korobeynikovb5e16af2011-03-05 18:43:15 +000020#include "llvm/MC/MCAsmInfo.h"
21#include "llvm/MC/MCContext.h"
22#include "llvm/MC/MCExpr.h"
23#include "llvm/MC/MCSection.h"
24#include "llvm/MC/MCStreamer.h"
25#include "llvm/MC/MCSymbol.h"
26#include "llvm/Target/Mangler.h"
27#include "llvm/Target/TargetData.h"
28#include "llvm/Target/TargetFrameLowering.h"
Anton Korobeynikovb5e16af2011-03-05 18:43:15 +000029#include "llvm/Target/TargetMachine.h"
30#include "llvm/Target/TargetOptions.h"
31#include "llvm/Target/TargetRegisterInfo.h"
32#include "llvm/Support/Dwarf.h"
33#include "llvm/Support/FormattedStream.h"
34#include "llvm/ADT/SmallString.h"
35#include "llvm/ADT/StringExtras.h"
36#include "llvm/ADT/Twine.h"
37using namespace llvm;
38
39ARMException::ARMException(AsmPrinter *A)
40 : DwarfException(A),
41 shouldEmitTable(false), shouldEmitMoves(false), shouldEmitTableModule(false)
42 {}
43
44ARMException::~ARMException() {}
45
46void ARMException::EndModule() {
47}
48
49/// BeginFunction - Gather pre-function exception information. Assumes it's
50/// being emitted immediately after the function entry point.
51void ARMException::BeginFunction(const MachineFunction *MF) {
52 Asm->OutStreamer.EmitFnStart();
Rafael Espindolafc2bb8c2011-05-25 03:44:17 +000053 if (Asm->MF->getFunction()->needsUnwindTableEntry())
Anton Korobeynikovb5e16af2011-03-05 18:43:15 +000054 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
55 Asm->getFunctionNumber()));
56}
57
58/// EndFunction - Gather and emit post-function exception information.
59///
60void ARMException::EndFunction() {
Rafael Espindolafc2bb8c2011-05-25 03:44:17 +000061 if (!Asm->MF->getFunction()->needsUnwindTableEntry())
Anton Korobeynikovb5e16af2011-03-05 18:43:15 +000062 Asm->OutStreamer.EmitCantUnwind();
63 else {
64 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
65 Asm->getFunctionNumber()));
66
67 // Emit references to personality.
68 if (const Function * Personality =
69 MMI->getPersonalities()[MMI->getPersonalityIndex()]) {
70 MCSymbol *PerSym = Asm->Mang->getSymbol(Personality);
71 Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global);
72 Asm->OutStreamer.EmitPersonality(PerSym);
73 }
74
Chandler Carruth3eb4be02012-01-24 00:30:17 +000075 // Map all labels and get rid of any dead landing pads.
76 MMI->TidyLandingPads();
Anton Korobeynikovb5e16af2011-03-05 18:43:15 +000077
Chandler Carruth3eb4be02012-01-24 00:30:17 +000078 Asm->OutStreamer.EmitHandlerData();
Anton Korobeynikovb5e16af2011-03-05 18:43:15 +000079
Chandler Carruth3eb4be02012-01-24 00:30:17 +000080 // Emit actual exception table
81 EmitExceptionTable();
Anton Korobeynikovb5e16af2011-03-05 18:43:15 +000082 }
83
84 Asm->OutStreamer.EmitFnEnd();
85}