Move some parts of TargetAsmInfo down to MCAsmInfo. This is not the greatest

solution but it is a small step towards removing the horror that is
TargetAsmInfo.

llvm-svn: 135237
This commit is contained in:
Evan Cheng 2011-07-15 02:09:41 +00:00
parent 9b8605f787
commit a83b37a9db
21 changed files with 125 additions and 84 deletions

View File

@ -37,6 +37,18 @@ namespace llvm {
//===------------------------------------------------------------------===//
// Properties to be set by the target writer, used to configure asm printer.
//
/// PointerSize - Pointer size in bytes.
/// Default is 4.
unsigned PointerSize;
/// IsLittleEndian - True if target is little endian.
/// Default is true.
bool IsLittleEndian;
/// StackGrowsUp - True if target stack grow up.
/// Default is false.
bool StackGrowsUp;
/// HasSubsectionsViaSymbols - True if this target has the MachO
/// .subsections_via_symbols directive.
@ -300,6 +312,21 @@ namespace llvm {
static unsigned getSLEB128Size(int Value);
static unsigned getULEB128Size(unsigned Value);
/// getPointerSize - Get the pointer size in bytes.
unsigned getPointerSize() const {
return PointerSize;
}
/// islittleendian - True if the target is little endian.
bool isLittleEndian() const {
return IsLittleEndian;
}
/// isStackGrowthDirectionUp - True if target stack grow up.
bool isStackGrowthDirectionUp() const {
return StackGrowsUp;
}
bool hasSubsectionsViaSymbols() const { return HasSubsectionsViaSymbols; }
// Data directive accessors.

View File

@ -28,9 +28,6 @@ namespace llvm {
class TargetLoweringObjectFile;
class TargetAsmInfo {
unsigned PointerSize;
bool IsLittleEndian;
TargetFrameLowering::StackDirection StackDir;
std::vector<MachineMove> InitialFrameState;
const TargetRegisterInfo *TRI;
const TargetFrameLowering *TFI;
@ -39,20 +36,6 @@ class TargetAsmInfo {
public:
explicit TargetAsmInfo(const TargetMachine &TM);
/// getPointerSize - Get the pointer size in bytes.
unsigned getPointerSize() const {
return PointerSize;
}
/// islittleendian - True if the target is little endian.
bool isLittleEndian() const {
return IsLittleEndian;
}
TargetFrameLowering::StackDirection getStackGrowthDirection() const {
return StackDir;
}
const MCSection *getDwarfLineSection() const {
return TLOF->getDwarfLineSection();
}

View File

@ -23,6 +23,9 @@
using namespace llvm;
MCAsmInfo::MCAsmInfo() {
PointerSize = 4;
IsLittleEndian = true;
StackGrowsUp = false;
HasSubsectionsViaSymbols = false;
HasMachoZeroFillDirective = false;
HasMachoTBSSDirective = false;

View File

@ -604,7 +604,7 @@ void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
int64_t IntValue;
if (!Value->EvaluateAsAbsolute(IntValue))
report_fatal_error("Don't know how to emit this value.");
if (getContext().getTargetAsmInfo().isLittleEndian()) {
if (getContext().getAsmInfo().isLittleEndian()) {
EmitIntValue((uint32_t)(IntValue >> 0 ), 4, AddrSpace);
EmitIntValue((uint32_t)(IntValue >> 32), 4, AddrSpace);
} else {
@ -827,8 +827,8 @@ void MCAsmStreamer::EmitCFIEndProc() {
void MCAsmStreamer::EmitRegisterName(int64_t Register) {
if (InstPrinter && !MAI.useDwarfRegNumForCFI()) {
const TargetAsmInfo &asmInfo = getContext().getTargetAsmInfo();
unsigned LLVMRegister = asmInfo.getLLVMRegNum(Register, true);
const TargetAsmInfo &TAI = getContext().getTargetAsmInfo();
unsigned LLVMRegister = TAI.getLLVMRegNum(Register, true);
InstPrinter->printRegName(OS, LLVMRegister);
} else {
OS << Register;
@ -1124,7 +1124,7 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {
unsigned Bit = (Code[i] >> j) & 1;
unsigned FixupBit;
if (getContext().getTargetAsmInfo().isLittleEndian())
if (getContext().getAsmInfo().isLittleEndian())
FixupBit = i * 8 + j;
else
FixupBit = i * 8 + (7-j);

View File

@ -172,7 +172,7 @@ static inline void EmitDwarfLineTable(MCStreamer *MCOS,
// At this point we want to emit/create the sequence to encode the delta in
// line numbers and the increment of the address from the previous Label
// and the current Label.
const TargetAsmInfo &asmInfo = MCOS->getContext().getTargetAsmInfo();
const MCAsmInfo &asmInfo = MCOS->getContext().getAsmInfo();
MCOS->EmitDwarfAdvanceLineAddr(LineDelta, LastLabel, Label,
asmInfo.getPointerSize());
@ -198,7 +198,7 @@ static inline void EmitDwarfLineTable(MCStreamer *MCOS,
// Switch back the the dwarf line section.
MCOS->SwitchSection(context.getTargetAsmInfo().getDwarfLineSection());
const TargetAsmInfo &asmInfo = MCOS->getContext().getTargetAsmInfo();
const MCAsmInfo &asmInfo = MCOS->getContext().getAsmInfo();
MCOS->EmitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, SectionEnd,
asmInfo.getPointerSize());
}
@ -431,25 +431,24 @@ void MCDwarfFile::dump() const {
static int getDataAlignmentFactor(MCStreamer &streamer) {
MCContext &context = streamer.getContext();
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
const MCAsmInfo &asmInfo = context.getAsmInfo();
int size = asmInfo.getPointerSize();
if (asmInfo.getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp)
if (asmInfo.isStackGrowthDirectionUp())
return size;
else
return -size;
else
return -size;
}
static unsigned getSizeForEncoding(MCStreamer &streamer,
unsigned symbolEncoding) {
MCContext &context = streamer.getContext();
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
unsigned format = symbolEncoding & 0x0f;
switch (format) {
default:
assert(0 && "Unknown Encoding");
case dwarf::DW_EH_PE_absptr:
case dwarf::DW_EH_PE_signed:
return asmInfo.getPointerSize();
return context.getAsmInfo().getPointerSize();
case dwarf::DW_EH_PE_udata2:
case dwarf::DW_EH_PE_sdata2:
return 2;
@ -486,11 +485,11 @@ static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol,
}
static const MachineLocation TranslateMachineLocation(
const TargetAsmInfo &AsmInfo,
const TargetAsmInfo &TAI,
const MachineLocation &Loc) {
unsigned Reg = Loc.getReg() == MachineLocation::VirtualFP ?
MachineLocation::VirtualFP :
unsigned(AsmInfo.getDwarfRegNum(Loc.getReg(), true));
unsigned(TAI.getDwarfRegNum(Loc.getReg(), true));
const MachineLocation &NewLoc = Loc.isReg() ?
MachineLocation(Reg) : MachineLocation(Reg, Loc.getOffset());
return NewLoc;
@ -772,11 +771,11 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
const MCSymbol *lsda,
unsigned lsdaEncoding) {
MCContext &context = streamer.getContext();
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
const TargetAsmInfo &TAI = context.getTargetAsmInfo();
bool verboseAsm = streamer.isVerboseAsm();
MCSymbol *sectionStart;
if (asmInfo.isFunctionEHFrameSymbolPrivate() || !IsEH)
if (TAI.isFunctionEHFrameSymbolPrivate() || !IsEH)
sectionStart = context.CreateTempSymbol();
else
sectionStart = context.GetOrCreateSymbol(Twine("EH_frame") + Twine(CIENum));
@ -825,7 +824,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
// Return Address Register
if (verboseAsm) streamer.AddComment("CIE Return Address Column");
streamer.EmitULEB128IntValue(asmInfo.getDwarfRARegNum(true));
streamer.EmitULEB128IntValue(TAI.getDwarfRARegNum(true));
// Augmentation Data Length (optional)
@ -859,21 +858,21 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
EmitEncodingByte(streamer, lsdaEncoding, "LSDA Encoding");
// Encoding of the FDE pointers
EmitEncodingByte(streamer, asmInfo.getFDEEncoding(UsingCFI),
EmitEncodingByte(streamer, TAI.getFDEEncoding(UsingCFI),
"FDE Encoding");
}
// Initial Instructions
const std::vector<MachineMove> &Moves = asmInfo.getInitialFrameState();
const std::vector<MachineMove> &Moves = TAI.getInitialFrameState();
std::vector<MCCFIInstruction> Instructions;
for (int i = 0, n = Moves.size(); i != n; ++i) {
MCSymbol *Label = Moves[i].getLabel();
const MachineLocation &Dst =
TranslateMachineLocation(asmInfo, Moves[i].getDestination());
TranslateMachineLocation(TAI, Moves[i].getDestination());
const MachineLocation &Src =
TranslateMachineLocation(asmInfo, Moves[i].getSource());
TranslateMachineLocation(TAI, Moves[i].getSource());
MCCFIInstruction Inst(Label, Dst, Src);
Instructions.push_back(Inst);
}
@ -881,7 +880,8 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
EmitCFIInstructions(streamer, Instructions, NULL);
// Padding
streamer.EmitValueToAlignment(IsEH ? 4 : asmInfo.getPointerSize());
streamer.EmitValueToAlignment(IsEH
? 4 : context.getAsmInfo().getPointerSize());
streamer.EmitLabel(sectionEnd);
return *sectionStart;
@ -893,10 +893,10 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer,
MCContext &context = streamer.getContext();
MCSymbol *fdeStart = context.CreateTempSymbol();
MCSymbol *fdeEnd = context.CreateTempSymbol();
const TargetAsmInfo &TAsmInfo = context.getTargetAsmInfo();
const TargetAsmInfo &TAI = context.getTargetAsmInfo();
bool verboseAsm = streamer.isVerboseAsm();
if (!TAsmInfo.isFunctionEHFrameSymbolPrivate() && IsEH) {
if (!TAI.isFunctionEHFrameSymbolPrivate() && IsEH) {
MCSymbol *EHSym =
context.GetOrCreateSymbol(frame.Function->getName() + Twine(".eh"));
streamer.EmitEHSymAttributes(frame.Function, EHSym);
@ -925,7 +925,7 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer,
streamer.EmitSymbolValue(&cieStart, 4);
}
unsigned fdeEncoding = TAsmInfo.getFDEEncoding(UsingCFI);
unsigned fdeEncoding = TAI.getFDEEncoding(UsingCFI);
unsigned size = getSizeForEncoding(streamer, fdeEncoding);
// PC Begin
@ -1011,9 +1011,9 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer,
bool UsingCFI,
bool IsEH) {
MCContext &Context = Streamer.getContext();
const TargetAsmInfo &AsmInfo = Context.getTargetAsmInfo();
const MCSection &Section = IsEH ? *AsmInfo.getEHFrameSection() :
*AsmInfo.getDwarfFrameSection();
const TargetAsmInfo &TAI = Context.getTargetAsmInfo();
const MCSection &Section = IsEH ? *TAI.getEHFrameSection() :
*TAI.getDwarfFrameSection();
Streamer.SwitchSection(&Section);
MCSymbol *SectionStart = Context.CreateTempSymbol();
Streamer.EmitLabel(SectionStart);
@ -1025,7 +1025,7 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer,
const MCSymbol *DummyDebugKey = NULL;
for (unsigned i = 0, n = Streamer.getNumFrameInfos(); i < n; ++i) {
const MCDwarfFrameInfo &Frame = Streamer.getFrameInfo(i);
if (IsEH && AsmInfo.getCompactUnwindSection() &&
if (IsEH && TAI.getCompactUnwindSection() &&
Emitter.EmitCompactUnwind(Streamer, Frame)) {
FDEEnd = NULL;
continue;
@ -1045,7 +1045,7 @@ void MCDwarfFrameEmitter::Emit(MCStreamer &Streamer,
Streamer.EmitLabel(FDEEnd);
}
Streamer.EmitValueToAlignment(AsmInfo.getPointerSize());
Streamer.EmitValueToAlignment(Context.getAsmInfo().getPointerSize());
if (FDEEnd)
Streamer.EmitLabel(FDEEnd);
}

View File

@ -401,14 +401,14 @@ bool COFFAsmParser::ParseAtUnwindOrAtExcept(bool &unwind, bool &except) {
bool COFFAsmParser::ParseSEHRegisterNumber(unsigned &RegNo) {
SMLoc startLoc = getLexer().getLoc();
if (getLexer().is(AsmToken::Percent)) {
const TargetAsmInfo &asmInfo = getContext().getTargetAsmInfo();
const TargetAsmInfo &TAI = getContext().getTargetAsmInfo();
SMLoc endLoc;
unsigned LLVMRegNo;
if (getParser().getTargetParser().ParseRegister(LLVMRegNo,startLoc,endLoc))
return true;
// Check that this is a non-volatile register.
const unsigned *NVRegs = asmInfo.getCalleeSavedRegs();
const unsigned *NVRegs = TAI.getCalleeSavedRegs();
unsigned i;
for (i = 0; NVRegs[i] != 0; ++i)
if (NVRegs[i] == LLVMRegNo)
@ -416,7 +416,7 @@ bool COFFAsmParser::ParseSEHRegisterNumber(unsigned &RegNo) {
if (NVRegs[i] == 0)
return Error(startLoc, "expected non-volatile register");
int SEHRegNo = asmInfo.getSEHRegNum(LLVMRegNo);
int SEHRegNo = TAI.getSEHRegNum(LLVMRegNo);
if (SEHRegNo < 0)
return Error(startLoc,"register can't be represented in SEH unwind info");
RegNo = SEHRegNo;

View File

@ -15,7 +15,6 @@
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Twine.h"
#include <cstdlib>
@ -81,7 +80,7 @@ void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size,
assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
"Invalid size");
char buf[8];
const bool isLittleEndian = Context.getTargetAsmInfo().isLittleEndian();
const bool isLittleEndian = Context.getAsmInfo().isLittleEndian();
for (unsigned i = 0; i != Size; ++i) {
unsigned index = isLittleEndian ? i : (Size - i - 1);
buf[i] = uint8_t(Value >> (index * 8));

View File

@ -225,9 +225,9 @@ void MCWin64EHUnwindEmitter::EmitUnwindInfo(MCStreamer &streamer,
// Switch sections (the static function above is meant to be called from
// here and from Emit().
MCContext &context = streamer.getContext();
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
const TargetAsmInfo &TAI = context.getTargetAsmInfo();
const MCSection *xdataSect =
asmInfo.getWin64EHTableSection(GetSectionSuffix(info->Function));
TAI.getWin64EHTableSection(GetSectionSuffix(info->Function));
streamer.SwitchSection(xdataSect);
llvm::EmitUnwindInfo(streamer, info);
@ -236,11 +236,11 @@ void MCWin64EHUnwindEmitter::EmitUnwindInfo(MCStreamer &streamer,
void MCWin64EHUnwindEmitter::Emit(MCStreamer &streamer) {
MCContext &context = streamer.getContext();
// Emit the unwind info structs first.
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
const TargetAsmInfo &TAI = context.getTargetAsmInfo();
for (unsigned i = 0; i < streamer.getNumW64UnwindInfos(); ++i) {
MCWin64EHUnwindInfo &info = streamer.getW64UnwindInfo(i);
const MCSection *xdataSect =
asmInfo.getWin64EHTableSection(GetSectionSuffix(info.Function));
TAI.getWin64EHTableSection(GetSectionSuffix(info.Function));
streamer.SwitchSection(xdataSect);
llvm::EmitUnwindInfo(streamer, &info);
}
@ -248,7 +248,7 @@ void MCWin64EHUnwindEmitter::Emit(MCStreamer &streamer) {
for (unsigned i = 0; i < streamer.getNumW64UnwindInfos(); ++i) {
MCWin64EHUnwindInfo &info = streamer.getW64UnwindInfo(i);
const MCSection *pdataSect =
asmInfo.getWin64EHFuncTableSection(GetSectionSuffix(info.Function));
TAI.getWin64EHFuncTableSection(GetSectionSuffix(info.Function));
streamer.SwitchSection(pdataSect);
EmitRuntimeFunction(streamer, &info);
}

View File

@ -128,7 +128,7 @@ extern "C" void LLVMInitializeARMMCRegInfo() {
TargetRegistry::RegisterMCRegInfo(TheThumbTarget, createARMMCRegisterInfo);
}
static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
static MCAsmInfo *createARMMCAsmInfo(const Target &T, StringRef TT) {
Triple TheTriple(TT);
if (TheTriple.isOSDarwin())
@ -139,6 +139,6 @@ static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
extern "C" void LLVMInitializeARMMCAsmInfo() {
// Register the target asm info.
RegisterMCAsmInfoFn A(TheARMTarget, createMCAsmInfo);
RegisterMCAsmInfoFn B(TheThumbTarget, createMCAsmInfo);
RegisterMCAsmInfoFn A(TheARMTarget, createARMMCAsmInfo);
RegisterMCAsmInfoFn B(TheThumbTarget, createARMMCAsmInfo);
}

View File

@ -15,6 +15,8 @@
using namespace llvm;
SPULinuxMCAsmInfo::SPULinuxMCAsmInfo(const Target &T, StringRef TT) {
IsLittleEndian = false;
ZeroDirective = "\t.space\t";
Data64bitsDirective = "\t.quad\t";
AlignmentIsInBytes = false;

View File

@ -15,6 +15,8 @@
using namespace llvm;
MBlazeMCAsmInfo::MBlazeMCAsmInfo() {
IsLittleEndian = false;
StackGrowsUp = false;
SupportsDebugInformation = true;
AlignmentIsInBytes = false;
PrivateGlobalPrefix = "$";

View File

@ -15,6 +15,8 @@
using namespace llvm;
MSP430MCAsmInfo::MSP430MCAsmInfo(const Target &T, StringRef TT) {
PointerSize = 2;
PrivateGlobalPrefix = ".L";
WeakRefDirective ="\t.weak\t";
PCSymbol=".";

View File

@ -12,9 +12,15 @@
//===----------------------------------------------------------------------===//
#include "MipsMCAsmInfo.h"
#include "llvm/ADT/Triple.h"
using namespace llvm;
MipsMCAsmInfo::MipsMCAsmInfo(const Target &T, StringRef TT) {
Triple TheTriple(TT);
if (TheTriple.getArch() == Triple::mips)
IsLittleEndian = false;
AlignmentIsInBytes = false;
Data16bitsDirective = "\t.2byte\t";
Data32bitsDirective = "\t.4byte\t";

View File

@ -12,10 +12,15 @@
//===----------------------------------------------------------------------===//
#include "PTXMCAsmInfo.h"
#include "llvm/ADT/Triple.h"
using namespace llvm;
PTXMCAsmInfo::PTXMCAsmInfo(const Target &T, const StringRef &TT) {
Triple TheTriple(TT);
if (TheTriple.getArch() == Triple::ptx64)
PointerSize = 8;
CommentString = "//";
PrivateGlobalPrefix = "$L__";

View File

@ -23,7 +23,6 @@
#include "llvm/Support/Format.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetAsmInfo.h"
using namespace llvm;
@ -369,7 +368,7 @@ void PTXMCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
int64_t IntValue;
if (!Value->EvaluateAsAbsolute(IntValue))
report_fatal_error("Don't know how to emit this value.");
if (getContext().getTargetAsmInfo().isLittleEndian()) {
if (getContext().getAsmInfo().isLittleEndian()) {
EmitIntValue((uint32_t)(IntValue >> 0 ), 4, AddrSpace);
EmitIntValue((uint32_t)(IntValue >> 32), 4, AddrSpace);
} else {

View File

@ -15,6 +15,10 @@
using namespace llvm;
PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit) {
if (is64Bit)
PointerSize = 8;
IsLittleEndian = false;
PCSymbol = ".";
CommentString = ";";
ExceptionsType = ExceptionHandling::DwarfCFI;

View File

@ -12,9 +12,16 @@
//===----------------------------------------------------------------------===//
#include "SparcMCAsmInfo.h"
#include "llvm/ADT/Triple.h"
using namespace llvm;
SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Target &T, StringRef TT) {
IsLittleEndian = false;
Triple TheTriple(TT);
if (TheTriple.getArch() == Triple::sparcv9)
PointerSize = 8;
Data16bitsDirective = "\t.half\t";
Data32bitsDirective = "\t.word\t";
Data64bitsDirective = 0; // .xword is only supported by V9.

View File

@ -18,6 +18,8 @@
using namespace llvm;
SystemZMCAsmInfo::SystemZMCAsmInfo(const Target &T, StringRef TT) {
IsLittleEndian = false;
PointerSize = 8;
PrivateGlobalPrefix = ".L";
WeakRefDirective = "\t.weak\t";
PCSymbol = ".";

View File

@ -17,12 +17,7 @@ using namespace llvm;
TargetAsmInfo::TargetAsmInfo(const TargetMachine &TM) {
TLOF = &TM.getTargetLowering()->getObjFileLowering();
const TargetData &TD = *TM.getTargetData();
IsLittleEndian = TD.isLittleEndian();
PointerSize = TD.getPointerSize();
TFI = TM.getFrameLowering();
StackDir = TFI->getStackGrowthDirection();
TRI = TM.getRegisterInfo();
TFI->getInitialFrameState(InitialFrameState);
}

View File

@ -49,12 +49,14 @@ static const char *const x86_asm_table[] = {
"{cc}", "cc",
0,0};
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) {
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
bool is64Bit = T.getArch() == Triple::x86_64;
if (is64Bit)
PointerSize = 8;
AsmTransCBE = x86_asm_table;
AssemblerDialect = AsmWriterFlavor;
bool is64Bit = Triple.getArch() == Triple::x86_64;
TextAlignFillValue = 0x90;
if (!is64Bit)
@ -75,22 +77,14 @@ X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &Triple) {
ExceptionsType = ExceptionHandling::DwarfCFI;
}
const MCExpr *
X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym,
unsigned Encoding,
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) {
if (T.getArch() == Triple::x86_64)
PointerSize = 8;
AsmTransCBE = x86_asm_table;
AssemblerDialect = AsmWriterFlavor;
@ -115,6 +109,17 @@ X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
Data64bitsDirective = 0;
}
const MCExpr *
X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym,
unsigned Encoding,
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);
}
const MCSection *X86ELFMCAsmInfo::
getNonexecutableStackSection(MCContext &Ctx) const {
return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS,

View File

@ -162,7 +162,7 @@ extern "C" void LLVMInitializeX86MCRegInfo() {
}
static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
static MCAsmInfo *createX86MCAsmInfo(const Target &T, StringRef TT) {
Triple TheTriple(TT);
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) {
@ -180,6 +180,6 @@ static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
extern "C" void LLVMInitializeX86MCAsmInfo() {
// Register the target asm info.
RegisterMCAsmInfoFn A(TheX86_32Target, createMCAsmInfo);
RegisterMCAsmInfoFn B(TheX86_64Target, createMCAsmInfo);
RegisterMCAsmInfoFn A(TheX86_32Target, createX86MCAsmInfo);
RegisterMCAsmInfoFn B(TheX86_64Target, createX86MCAsmInfo);
}