mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-02 13:21:43 +00:00
Add a getExprForPersonalitySymbol method to MCAsmInfo. Use it when
converting the symbol passed to .cfi_personality into bytes is the file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8bca4106df
commit
bfa27cc5d7
@ -20,7 +20,10 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class MCExpr;
|
||||||
class MCSection;
|
class MCSection;
|
||||||
|
class MCStreamer;
|
||||||
|
class MCSymbol;
|
||||||
class MCContext;
|
class MCContext;
|
||||||
|
|
||||||
/// MCAsmInfo - This class is intended to be used as a base class for asm
|
/// MCAsmInfo - This class is intended to be used as a base class for asm
|
||||||
@ -321,6 +324,10 @@ namespace llvm {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual const MCExpr *
|
||||||
|
getExprForPersonalitySymbol(const MCSymbol *Sym,
|
||||||
|
MCStreamer &Streamer) const;
|
||||||
|
|
||||||
bool usesSunStyleELFSectionSwitchSyntax() const {
|
bool usesSunStyleELFSectionSwitchSyntax() const {
|
||||||
return SunStyleELFSectionSwitchSyntax;
|
return SunStyleELFSectionSwitchSyntax;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,9 @@ namespace llvm {
|
|||||||
|
|
||||||
struct MCAsmInfoDarwin : public MCAsmInfo {
|
struct MCAsmInfoDarwin : public MCAsmInfo {
|
||||||
explicit MCAsmInfoDarwin();
|
explicit MCAsmInfoDarwin();
|
||||||
|
virtual const MCExpr *
|
||||||
|
getExprForPersonalitySymbol(const MCSymbol *Sym,
|
||||||
|
MCStreamer &Streamer) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
|
#include "llvm/MC/MCExpr.h"
|
||||||
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -106,3 +108,9 @@ unsigned MCAsmInfo::getSLEB128Size(int Value) {
|
|||||||
} while (IsMore);
|
} while (IsMore);
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MCExpr *
|
||||||
|
MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
|
||||||
|
MCStreamer &Streamer) const {
|
||||||
|
return MCSymbolRefExpr::Create(Sym, Streamer.getContext());
|
||||||
|
}
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/MC/MCAsmInfoDarwin.h"
|
#include "llvm/MC/MCAsmInfoDarwin.h"
|
||||||
|
#include "llvm/MC/MCContext.h"
|
||||||
|
#include "llvm/MC/MCExpr.h"
|
||||||
|
#include "llvm/MC/MCStreamer.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
MCAsmInfoDarwin::MCAsmInfoDarwin() {
|
MCAsmInfoDarwin::MCAsmInfoDarwin() {
|
||||||
@ -57,3 +60,13 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
|
|||||||
DwarfUsesLabelOffsetForRanges = false;
|
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);
|
||||||
|
}
|
||||||
|
@ -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(
|
static const MachineLocation TranslateMachineLocation(
|
||||||
const TargetAsmInfo &AsmInfo,
|
const TargetAsmInfo &AsmInfo,
|
||||||
const MachineLocation &Loc) {
|
const MachineLocation &Loc) {
|
||||||
@ -681,7 +694,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
|
|||||||
// Personality Encoding
|
// Personality Encoding
|
||||||
streamer.EmitIntValue(personalityEncoding, 1);
|
streamer.EmitIntValue(personalityEncoding, 1);
|
||||||
// Personality
|
// Personality
|
||||||
EmitSymbol(streamer, *personality, personalityEncoding);
|
EmitPersonality(streamer, *personality, personalityEncoding);
|
||||||
}
|
}
|
||||||
if (lsda) {
|
if (lsda) {
|
||||||
// LSDA Encoding
|
// LSDA Encoding
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
#include "X86TargetMachine.h"
|
#include "X86TargetMachine.h"
|
||||||
#include "llvm/ADT/Triple.h"
|
#include "llvm/ADT/Triple.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCSectionELF.h"
|
#include "llvm/MC/MCSectionELF.h"
|
||||||
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/ELF.h"
|
#include "llvm/Support/ELF.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
@ -72,6 +74,20 @@ X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) {
|
|||||||
ExceptionsType = ExceptionHandling::DwarfTable;
|
ExceptionsType = ExceptionHandling::DwarfTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MCExpr *
|
||||||
|
X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym,
|
||||||
|
MCStreamer &Streamer) const {
|
||||||
|
MCContext &Context = Streamer.getContext();
|
||||||
|
const MCExpr *Res =
|
||||||
|
MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Context);
|
||||||
|
const MCExpr *Four = MCConstantExpr::Create(4, Context);
|
||||||
|
return MCBinaryExpr::CreateAdd(Res, Four, Context);
|
||||||
|
}
|
||||||
|
|
||||||
|
X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)
|
||||||
|
: X86MCAsmInfoDarwin(Triple) {
|
||||||
|
}
|
||||||
|
|
||||||
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
|
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
|
||||||
AsmTransCBE = x86_asm_table;
|
AsmTransCBE = x86_asm_table;
|
||||||
AssemblerDialect = AsmWriterFlavor;
|
AssemblerDialect = AsmWriterFlavor;
|
||||||
|
@ -25,6 +25,13 @@ namespace llvm {
|
|||||||
explicit X86MCAsmInfoDarwin(const Triple &Triple);
|
explicit X86MCAsmInfoDarwin(const Triple &Triple);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct X86_64MCAsmInfoDarwin : public X86MCAsmInfoDarwin {
|
||||||
|
explicit X86_64MCAsmInfoDarwin(const Triple &Triple);
|
||||||
|
virtual const MCExpr *
|
||||||
|
getExprForPersonalitySymbol(const MCSymbol *Sym,
|
||||||
|
MCStreamer &Streamer) const;
|
||||||
|
};
|
||||||
|
|
||||||
struct X86ELFMCAsmInfo : public MCAsmInfo {
|
struct X86ELFMCAsmInfo : public MCAsmInfo {
|
||||||
explicit X86ELFMCAsmInfo(const Triple &Triple);
|
explicit X86ELFMCAsmInfo(const Triple &Triple);
|
||||||
virtual const MCSection *getNonexecutableStackSection(MCContext &Ctx) const;
|
virtual const MCSection *getNonexecutableStackSection(MCContext &Ctx) const;
|
||||||
|
@ -27,8 +27,12 @@ using namespace llvm;
|
|||||||
static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
|
static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
|
||||||
Triple TheTriple(TT);
|
Triple TheTriple(TT);
|
||||||
|
|
||||||
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
|
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) {
|
||||||
return new X86MCAsmInfoDarwin(TheTriple);
|
if (TheTriple.getArch() == Triple::x86_64)
|
||||||
|
return new X86_64MCAsmInfoDarwin(TheTriple);
|
||||||
|
else
|
||||||
|
return new X86MCAsmInfoDarwin(TheTriple);
|
||||||
|
}
|
||||||
|
|
||||||
if (TheTriple.isOSWindows())
|
if (TheTriple.isOSWindows())
|
||||||
return new X86MCAsmInfoCOFF(TheTriple);
|
return new X86MCAsmInfoCOFF(TheTriple);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user