1 //===-- CodeGen/AsmPrinter/ARMException.cpp - ARM EHABI Exception Impl ----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains support for writing DWARF exception info into asm files.
12 //===----------------------------------------------------------------------===//
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"
20 #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"
29 #include "llvm/Target/TargetLoweringObjectFile.h"
30 #include "llvm/Target/TargetMachine.h"
31 #include "llvm/Target/TargetOptions.h"
32 #include "llvm/Target/TargetRegisterInfo.h"
33 #include "llvm/Support/Dwarf.h"
34 #include "llvm/Support/FormattedStream.h"
35 #include "llvm/ADT/SmallString.h"
36 #include "llvm/ADT/StringExtras.h"
37 #include "llvm/ADT/Twine.h"
40 ARMException::ARMException(AsmPrinter *A)
42 shouldEmitTable(false), shouldEmitMoves(false), shouldEmitTableModule(false)
45 ARMException::~ARMException() {}
47 void ARMException::EndModule() {
50 /// BeginFunction - Gather pre-function exception information. Assumes it's
51 /// being emitted immediately after the function entry point.
52 void ARMException::BeginFunction(const MachineFunction *MF) {
53 Asm->OutStreamer.EmitFnStart();
54 if (Asm->MF->getFunction()->needsUnwindTableEntry())
55 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
56 Asm->getFunctionNumber()));
59 /// EndFunction - Gather and emit post-function exception information.
61 void ARMException::EndFunction() {
62 if (!Asm->MF->getFunction()->needsUnwindTableEntry())
63 Asm->OutStreamer.EmitCantUnwind();
65 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
66 Asm->getFunctionNumber()));
68 // Emit references to personality.
69 if (const Function * Personality =
70 MMI->getPersonalities()[MMI->getPersonalityIndex()]) {
71 MCSymbol *PerSym = Asm->Mang->getSymbol(Personality);
72 Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global);
73 Asm->OutStreamer.EmitPersonality(PerSym);
76 // Map all labels and get rid of any dead landing pads.
77 MMI->TidyLandingPads();
79 Asm->OutStreamer.EmitHandlerData();
81 // Emit actual exception table
85 Asm->OutStreamer.EmitFnEnd();