diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-04-28 16:09:09 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-04-28 16:09:09 +0000 |
| commit | c5dac4df2ea91969604a12d418954ab026603c99 (patch) | |
| tree | d286aeaf901a2f683e062b41fe795319edd5cda0 /llvm/lib/MC | |
| parent | 068730992cf08d7d7e82e7bb147d85f429fc3ddd (diff) | |
| download | bcm5719-llvm-c5dac4df2ea91969604a12d418954ab026603c99.tar.gz bcm5719-llvm-c5dac4df2ea91969604a12d418954ab026603c99.zip | |
Add a getExprForPersonalitySymbol method to MCAsmInfo. Use it when
converting the symbol passed to .cfi_personality into bytes is the file.
llvm-svn: 130400
Diffstat (limited to 'llvm/lib/MC')
| -rw-r--r-- | llvm/lib/MC/MCAsmInfo.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/MC/MCAsmInfoDarwin.cpp | 13 | ||||
| -rw-r--r-- | llvm/lib/MC/MCDwarf.cpp | 15 |
3 files changed, 35 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp index 116c007a451..873802ae980 100644 --- a/llvm/lib/MC/MCAsmInfo.cpp +++ b/llvm/lib/MC/MCAsmInfo.cpp @@ -13,6 +13,8 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCStreamer.h" #include "llvm/Support/DataTypes.h" #include <cctype> #include <cstring> @@ -106,3 +108,9 @@ unsigned MCAsmInfo::getSLEB128Size(int Value) { } while (IsMore); return Size; } + +const MCExpr * +MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const { + return MCSymbolRefExpr::Create(Sym, Streamer.getContext()); +} diff --git a/llvm/lib/MC/MCAsmInfoDarwin.cpp b/llvm/lib/MC/MCAsmInfoDarwin.cpp index 526ad0da42a..04862fae161 100644 --- a/llvm/lib/MC/MCAsmInfoDarwin.cpp +++ b/llvm/lib/MC/MCAsmInfoDarwin.cpp @@ -13,6 +13,9 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmInfoDarwin.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCStreamer.h" using namespace llvm; MCAsmInfoDarwin::MCAsmInfoDarwin() { @@ -57,3 +60,13 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() { DwarfUsesLabelOffsetForRanges = false; } +const MCExpr * +MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const { + MCContext &Context = Streamer.getContext(); + const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context); + MCSymbol *PCSym = Context.CreateTempSymbol(); + Streamer.EmitLabel(PCSym); + const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context); + return MCBinaryExpr::CreateSub(Res, PC, Context); +} diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp index 974bcba7c7e..d677d0c3b61 100644 --- a/llvm/lib/MC/MCDwarf.cpp +++ b/llvm/lib/MC/MCDwarf.cpp @@ -480,6 +480,19 @@ static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol, } } +static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol, + unsigned symbolEncoding) { + MCContext &context = streamer.getContext(); + const MCAsmInfo &asmInfo = context.getAsmInfo(); + const MCExpr *v = asmInfo.getExprForPersonalitySymbol(&symbol, streamer); + unsigned size = getSizeForEncoding(streamer, symbolEncoding); + unsigned application = symbolEncoding & 0x70; + if (isa<MCSymbolRefExpr>(v) && application == dwarf::DW_EH_PE_pcrel) + streamer.EmitPCRelValue(v, size); + else + streamer.EmitValue(v, size); +} + static const MachineLocation TranslateMachineLocation( const TargetAsmInfo &AsmInfo, const MachineLocation &Loc) { @@ -681,7 +694,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer, // Personality Encoding streamer.EmitIntValue(personalityEncoding, 1); // Personality - EmitSymbol(streamer, *personality, personalityEncoding); + EmitPersonality(streamer, *personality, personalityEncoding); } if (lsda) { // LSDA Encoding |

