Anton Korobeynikov | b5e16af | 2011-03-05 18:43:15 +0000 | [diff] [blame^] | 1 | //===-- 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" |
| 20 | #include "llvm/CodeGen/MachineLocation.h" |
| 21 | #include "llvm/MC/MCAsmInfo.h" |
| 22 | #include "llvm/MC/MCContext.h" |
| 23 | #include "llvm/MC/MCExpr.h" |
| 24 | #include "llvm/MC/MCSection.h" |
| 25 | #include "llvm/MC/MCStreamer.h" |
| 26 | #include "llvm/MC/MCSymbol.h" |
| 27 | #include "llvm/Target/Mangler.h" |
| 28 | #include "llvm/Target/TargetData.h" |
| 29 | #include "llvm/Target/TargetFrameLowering.h" |
| 30 | #include "llvm/Target/TargetLoweringObjectFile.h" |
| 31 | #include "llvm/Target/TargetMachine.h" |
| 32 | #include "llvm/Target/TargetOptions.h" |
| 33 | #include "llvm/Target/TargetRegisterInfo.h" |
| 34 | #include "llvm/Support/Dwarf.h" |
| 35 | #include "llvm/Support/FormattedStream.h" |
| 36 | #include "llvm/ADT/SmallString.h" |
| 37 | #include "llvm/ADT/StringExtras.h" |
| 38 | #include "llvm/ADT/Twine.h" |
| 39 | using namespace llvm; |
| 40 | |
| 41 | ARMException::ARMException(AsmPrinter *A) |
| 42 | : DwarfException(A), |
| 43 | shouldEmitTable(false), shouldEmitMoves(false), shouldEmitTableModule(false) |
| 44 | {} |
| 45 | |
| 46 | ARMException::~ARMException() {} |
| 47 | |
| 48 | void ARMException::EndModule() { |
| 49 | } |
| 50 | |
| 51 | /// BeginFunction - Gather pre-function exception information. Assumes it's |
| 52 | /// being emitted immediately after the function entry point. |
| 53 | void ARMException::BeginFunction(const MachineFunction *MF) { |
| 54 | Asm->OutStreamer.EmitFnStart(); |
| 55 | if (!Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory) |
| 56 | Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin", |
| 57 | Asm->getFunctionNumber())); |
| 58 | } |
| 59 | |
| 60 | /// EndFunction - Gather and emit post-function exception information. |
| 61 | /// |
| 62 | void ARMException::EndFunction() { |
| 63 | if (Asm->MF->getFunction()->doesNotThrow() && !UnwindTablesMandatory) |
| 64 | Asm->OutStreamer.EmitCantUnwind(); |
| 65 | else { |
| 66 | Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end", |
| 67 | Asm->getFunctionNumber())); |
| 68 | |
| 69 | // Emit references to personality. |
| 70 | if (const Function * Personality = |
| 71 | MMI->getPersonalities()[MMI->getPersonalityIndex()]) { |
| 72 | MCSymbol *PerSym = Asm->Mang->getSymbol(Personality); |
| 73 | Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global); |
| 74 | Asm->OutStreamer.EmitPersonality(PerSym); |
| 75 | } |
| 76 | |
| 77 | // Map all labels and get rid of any dead landing pads. |
| 78 | MMI->TidyLandingPads(); |
| 79 | |
| 80 | Asm->OutStreamer.EmitHandlerData(); |
| 81 | |
| 82 | // Emit actual exception table |
| 83 | EmitExceptionTable(); |
| 84 | } |
| 85 | |
| 86 | Asm->OutStreamer.EmitFnEnd(); |
| 87 | } |