mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Goodbye TargetAsmInfo. This eliminate last bit of CodeGen and Target in llvm-mc.
There is still a bit more refactoring left to do in Targets. But we are now very close to fixing all the layering issues in MC. llvm-svn: 135611
This commit is contained in:
parent
73b85ba883
commit
c9bc5a9011
@ -175,8 +175,7 @@ public:
|
||||
MachineModuleInfo(); // DUMMY CONSTRUCTOR, DO NOT CALL.
|
||||
// Real constructor.
|
||||
MachineModuleInfo(const MCAsmInfo &MAI, const MCRegisterInfo &MRI,
|
||||
const MCObjectFileInfo *MOFI,
|
||||
const TargetAsmInfo *TAI);
|
||||
const MCObjectFileInfo *MOFI);
|
||||
~MachineModuleInfo();
|
||||
|
||||
bool doInitialization();
|
||||
|
@ -100,11 +100,6 @@ public:
|
||||
virtual MCSymbol *
|
||||
getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
||||
MachineModuleInfo *MMI) const;
|
||||
|
||||
virtual unsigned getPersonalityEncoding() const;
|
||||
virtual unsigned getLSDAEncoding() const;
|
||||
virtual unsigned getFDEEncoding(bool CFI) const;
|
||||
virtual unsigned getTTypeEncoding() const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -31,7 +31,6 @@ namespace llvm {
|
||||
class MCLineSection;
|
||||
class StringRef;
|
||||
class Twine;
|
||||
class TargetAsmInfo;
|
||||
class MCSectionMachO;
|
||||
class MCSectionELF;
|
||||
|
||||
@ -54,8 +53,6 @@ namespace llvm {
|
||||
/// The MCObjectFileInfo for this target.
|
||||
const MCObjectFileInfo *MOFI;
|
||||
|
||||
const TargetAsmInfo *TAI;
|
||||
|
||||
/// Allocator - Allocator object used for creating machine code objects.
|
||||
///
|
||||
/// We use a bump pointer allocator to avoid the need to track all allocated
|
||||
@ -119,7 +116,7 @@ namespace llvm {
|
||||
|
||||
public:
|
||||
explicit MCContext(const MCAsmInfo &MAI, const MCRegisterInfo &MRI,
|
||||
const MCObjectFileInfo *MOFI, const TargetAsmInfo *TAI);
|
||||
const MCObjectFileInfo *MOFI);
|
||||
~MCContext();
|
||||
|
||||
const MCAsmInfo &getAsmInfo() const { return MAI; }
|
||||
@ -128,8 +125,6 @@ namespace llvm {
|
||||
|
||||
const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
|
||||
|
||||
const TargetAsmInfo &getTargetAsmInfo() const { return *TAI; }
|
||||
|
||||
void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
|
||||
|
||||
/// @name Symbol Management
|
||||
|
@ -40,6 +40,13 @@ protected:
|
||||
/// non-.globl label. This defaults to true.
|
||||
bool IsFunctionEHFrameSymbolPrivate;
|
||||
|
||||
/// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
|
||||
/// encoding values for EH.
|
||||
unsigned PersonalityEncoding;
|
||||
unsigned LSDAEncoding;
|
||||
unsigned FDEEncoding;
|
||||
unsigned FDECFIEncoding;
|
||||
unsigned TTypeEncoding;
|
||||
|
||||
/// TextSection - Section directive for standard text.
|
||||
///
|
||||
@ -151,7 +158,8 @@ protected:
|
||||
const MCSection *XDataSection;
|
||||
|
||||
public:
|
||||
void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, MCContext &ctx);
|
||||
void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
|
||||
MCContext &ctx);
|
||||
|
||||
bool isFunctionEHFrameSymbolPrivate() const {
|
||||
return IsFunctionEHFrameSymbolPrivate;
|
||||
@ -163,6 +171,13 @@ public:
|
||||
return CommDirectiveSupportsAlignment;
|
||||
}
|
||||
|
||||
unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
|
||||
unsigned getLSDAEncoding() const { return LSDAEncoding; }
|
||||
unsigned getFDEEncoding(bool CFI) const {
|
||||
return CFI ? FDECFIEncoding : FDEEncoding;
|
||||
}
|
||||
unsigned getTTypeEncoding() const { return TTypeEncoding; }
|
||||
|
||||
const MCSection *getTextSection() const { return TextSection; }
|
||||
const MCSection *getDataSection() const { return DataSection; }
|
||||
const MCSection *getBSSSection() const { return BSSSection; }
|
||||
@ -262,6 +277,7 @@ private:
|
||||
enum Environment { IsMachO, IsELF, IsCOFF };
|
||||
Environment Env;
|
||||
Reloc::Model RelocM;
|
||||
CodeModel::Model CMModel;
|
||||
MCContext *Ctx;
|
||||
|
||||
void InitMachOMCObjectFileInfo(Triple T);
|
||||
|
@ -1,35 +0,0 @@
|
||||
//===-- llvm/Target/TargetAsmInfo.h -----------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Interface to provide the information necessary for producing assembly files.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TARGET_TARGETASMINFO_H
|
||||
#define LLVM_TARGET_TARGETASMINFO_H
|
||||
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
|
||||
namespace llvm {
|
||||
class TargetMachine;
|
||||
class TargetLoweringObjectFile;
|
||||
|
||||
class TargetAsmInfo {
|
||||
const TargetLoweringObjectFile *TLOF;
|
||||
|
||||
public:
|
||||
explicit TargetAsmInfo(const TargetMachine &TM);
|
||||
|
||||
unsigned getFDEEncoding(bool CFI) const {
|
||||
return TLOF->getFDEEncoding(CFI);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
@ -122,11 +122,6 @@ public:
|
||||
getExprForDwarfReference(const MCSymbol *Sym, unsigned Encoding,
|
||||
MCStreamer &Streamer) const;
|
||||
|
||||
virtual unsigned getPersonalityEncoding() const;
|
||||
virtual unsigned getLSDAEncoding() const;
|
||||
virtual unsigned getFDEEncoding(bool CFI) const;
|
||||
virtual unsigned getTTypeEncoding() const;
|
||||
|
||||
protected:
|
||||
virtual const MCSection *
|
||||
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/Target/Mangler.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
|
@ -45,7 +45,6 @@
|
||||
#include "llvm/MC/MCSectionELF.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/Target/Mangler.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetELFWriterInfo.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
@ -67,8 +66,7 @@ char ELFWriter::ID = 0;
|
||||
ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm)
|
||||
: MachineFunctionPass(ID), O(o), TM(tm),
|
||||
OutContext(*new MCContext(*TM.getMCAsmInfo(), *TM.getRegisterInfo(),
|
||||
&TM.getTargetLowering()->getObjFileLowering(),
|
||||
new TargetAsmInfo(tm))),
|
||||
&TM.getTargetLowering()->getObjFileLowering())),
|
||||
TLOF(TM.getTargetLowering()->getObjFileLowering()),
|
||||
is64Bit(TM.getTargetData()->getPointerSizeInBits() == 64),
|
||||
isLittleEndian(TM.getTargetData()->isLittleEndian()),
|
||||
|
@ -27,9 +27,10 @@
|
||||
#include "llvm/MC/MCInstrInfo.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetInstrInfo.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
@ -353,11 +354,9 @@ bool LLVMTargetMachine::addCommonCodeGenPasses(PassManagerBase &PM,
|
||||
|
||||
// Install a MachineModuleInfo class, which is an immutable pass that holds
|
||||
// all the per-module stuff we're generating, including MCContext.
|
||||
TargetAsmInfo *TAI = new TargetAsmInfo(*this);
|
||||
MachineModuleInfo *MMI = new MachineModuleInfo(*getMCAsmInfo(),
|
||||
*getRegisterInfo(),
|
||||
&getTargetLowering()->getObjFileLowering(),
|
||||
TAI);
|
||||
&getTargetLowering()->getObjFileLowering());
|
||||
PM.add(MMI);
|
||||
OutContext = &MMI->getContext(); // Return the MCContext specifically by-ref.
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/Passes.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/MC/MCObjectFileInfo.h"
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/ADT/PointerUnion.h"
|
||||
@ -254,9 +253,8 @@ void MMIAddrLabelMapCallbackPtr::allUsesReplacedWith(Value *V2) {
|
||||
|
||||
MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI,
|
||||
const MCRegisterInfo &MRI,
|
||||
const MCObjectFileInfo *MOFI,
|
||||
const TargetAsmInfo *TAI)
|
||||
: ImmutablePass(ID), Context(MAI, MRI, MOFI, TAI),
|
||||
const MCObjectFileInfo *MOFI)
|
||||
: ImmutablePass(ID), Context(MAI, MRI, MOFI),
|
||||
ObjFileMMI(0), CompactUnwindEncoding(0), CurCallSite(0), CallsEHReturn(0),
|
||||
CallsUnwindInit(0), DbgInfoAvailable(false),
|
||||
CallsExternalVAFunctionWithFloatingPointArguments(false) {
|
||||
@ -269,7 +267,7 @@ MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI,
|
||||
|
||||
MachineModuleInfo::MachineModuleInfo()
|
||||
: ImmutablePass(ID),
|
||||
Context(*(MCAsmInfo*)0, *(MCRegisterInfo*)0, (MCObjectFileInfo*)0, NULL) {
|
||||
Context(*(MCAsmInfo*)0, *(MCRegisterInfo*)0, (MCObjectFileInfo*)0) {
|
||||
assert(0 && "This MachineModuleInfo constructor should never be called, MMI "
|
||||
"should always be explicitly constructed by LLVMTargetMachine");
|
||||
abort();
|
||||
|
@ -543,22 +543,6 @@ getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
||||
return SSym;
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFileMachO::getPersonalityEncoding() const {
|
||||
return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFileMachO::getLSDAEncoding() const {
|
||||
return DW_EH_PE_pcrel;
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFileMachO::getFDEEncoding(bool CFI) const {
|
||||
return DW_EH_PE_pcrel;
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFileMachO::getTTypeEncoding() const {
|
||||
return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// COFF
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "llvm/Target/TargetAsmBackend.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
#include <cctype>
|
||||
using namespace llvm;
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/MC/MCLabel.h"
|
||||
#include "llvm/MC/MCDwarf.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
#include "llvm/Support/ELF.h"
|
||||
@ -29,8 +28,8 @@ typedef StringMap<const MCSectionCOFF*> COFFUniqueMapTy;
|
||||
|
||||
|
||||
MCContext::MCContext(const MCAsmInfo &mai, const MCRegisterInfo &mri,
|
||||
const MCObjectFileInfo *mofi, const TargetAsmInfo *tai) :
|
||||
MAI(mai), MRI(mri), MOFI(mofi), TAI(tai),
|
||||
const MCObjectFileInfo *mofi) :
|
||||
MAI(mai), MRI(mri), MOFI(mofi),
|
||||
Allocator(), Symbols(Allocator), UsedNames(Allocator),
|
||||
NextUniqueID(0),
|
||||
CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0),
|
||||
@ -57,8 +56,6 @@ MCContext::~MCContext() {
|
||||
|
||||
// If the stream for the .secure_log_unique directive was created free it.
|
||||
delete (raw_ostream*)SecureLog;
|
||||
|
||||
delete TAI;
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -17,8 +17,6 @@
|
||||
#include "llvm/MC/MCInstPrinter.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h" // FIXME.
|
||||
#include "llvm/Target/TargetMachine.h" // FIXME.
|
||||
#include "llvm/Target/TargetSelect.h"
|
||||
#include "llvm/Support/MemoryObject.h"
|
||||
|
||||
@ -39,8 +37,6 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
||||
LLVMSymbolLookupCallback SymbolLookUp) {
|
||||
// Initialize targets and assembly printers/parsers.
|
||||
llvm::InitializeAllTargetInfos();
|
||||
// FIXME: We shouldn't need to initialize the Target(Machine)s.
|
||||
llvm::InitializeAllTargets();
|
||||
llvm::InitializeAllMCAsmInfos();
|
||||
llvm::InitializeAllMCCodeGenInfos();
|
||||
llvm::InitializeAllMCRegisterInfos();
|
||||
@ -64,19 +60,8 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
||||
std::string FeaturesStr;
|
||||
std::string CPU;
|
||||
|
||||
// FIXME: We shouldn't need to do this (and link in codegen).
|
||||
// When we split this out, we should do it in a way that makes
|
||||
// it straightforward to switch subtargets on the fly.
|
||||
TargetMachine *TM = TheTarget->createTargetMachine(TripleName, CPU,
|
||||
FeaturesStr);
|
||||
assert(TM && "Unable to create target machine!");
|
||||
|
||||
// Get the target assembler info needed to setup the context.
|
||||
const TargetAsmInfo *tai = new TargetAsmInfo(*TM);
|
||||
assert(tai && "Unable to create target assembler!");
|
||||
|
||||
// Set up the MCContext for creating symbols and MCExpr's.
|
||||
MCContext *Ctx = new MCContext(*MAI, *MRI, 0, tai);
|
||||
MCContext *Ctx = new MCContext(*MAI, *MRI, 0);
|
||||
assert(Ctx && "Unable to create MCContext!");
|
||||
|
||||
// Set up disassembler.
|
||||
@ -92,7 +77,7 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
|
||||
|
||||
LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType,
|
||||
GetOpInfo, SymbolLookUp,
|
||||
TheTarget, MAI, MRI, TM, tai,
|
||||
TheTarget, MAI, MRI,
|
||||
Ctx, DisAsm, IP);
|
||||
assert(DC && "Allocation failure!");
|
||||
return DC;
|
||||
|
@ -22,14 +22,12 @@
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
|
||||
namespace llvm {
|
||||
class TargetAsmInfo;
|
||||
class MCContext;
|
||||
class MCAsmInfo;
|
||||
class MCDisassembler;
|
||||
class MCInstPrinter;
|
||||
class MCRegisterInfo;
|
||||
class Target;
|
||||
class TargetMachine;
|
||||
|
||||
//
|
||||
// This is the disassembler context returned by LLVMCreateDisasm().
|
||||
@ -61,12 +59,6 @@ private:
|
||||
llvm::OwningPtr<const llvm::MCAsmInfo> MAI;
|
||||
// The register information for the target architecture.
|
||||
llvm::OwningPtr<const llvm::MCRegisterInfo> MRI;
|
||||
// The target machine instance.
|
||||
llvm::OwningPtr<llvm::TargetMachine> TM;
|
||||
// The disassembler for the target architecture.
|
||||
// FIXME: using llvm::OwningPtr<const llvm::TargetAsmInfo> causes a malloc
|
||||
// error when this LLVMDisasmContext is deleted.
|
||||
const TargetAsmInfo *Tai;
|
||||
// The assembly context for creating symbols and MCExprs.
|
||||
llvm::OwningPtr<const llvm::MCContext> Ctx;
|
||||
// The disassembler for the target architecture.
|
||||
@ -80,12 +72,10 @@ public:
|
||||
LLVMSymbolLookupCallback symbolLookUp,
|
||||
const Target *theTarget, const MCAsmInfo *mAI,
|
||||
const MCRegisterInfo *mRI,
|
||||
llvm::TargetMachine *tM, const TargetAsmInfo *tai,
|
||||
llvm::MCContext *ctx, const MCDisassembler *disAsm,
|
||||
MCInstPrinter *iP) : TripleName(tripleName),
|
||||
DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo),
|
||||
SymbolLookUp(symbolLookUp), TheTarget(theTarget), Tai(tai) {
|
||||
TM.reset(tM);
|
||||
SymbolLookUp(symbolLookUp), TheTarget(theTarget) {
|
||||
MAI.reset(mAI);
|
||||
MRI.reset(mRI);
|
||||
Ctx.reset(ctx);
|
||||
|
@ -377,7 +377,7 @@ int EDDisassembler::parseInst(SmallVectorImpl<MCParsedAsmOperand*> &operands,
|
||||
SourceMgr sourceMgr;
|
||||
sourceMgr.setDiagHandler(diag_handler, static_cast<void*>(this));
|
||||
sourceMgr.AddNewSourceBuffer(buf, SMLoc()); // ownership of buf handed over
|
||||
MCContext context(*AsmInfo, *MRI, NULL, NULL);
|
||||
MCContext context(*AsmInfo, *MRI, NULL);
|
||||
OwningPtr<MCStreamer> streamer(createNullStreamer(context));
|
||||
OwningPtr<MCAsmParser> genericParser(createMCAsmParser(*Tgt, sourceMgr,
|
||||
context, *streamer,
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
@ -691,7 +690,6 @@ bool FrameEmitterImpl::EmitCompactUnwind(MCStreamer &Streamer,
|
||||
const MCDwarfFrameInfo &Frame) {
|
||||
MCContext &Context = Streamer.getContext();
|
||||
const MCObjectFileInfo *MOFI = Context.getObjectFileInfo();
|
||||
const TargetAsmInfo &TAI = Context.getTargetAsmInfo();
|
||||
bool VerboseAsm = Streamer.isVerboseAsm();
|
||||
|
||||
// range-start range-length compact-unwind-enc personality-func lsda
|
||||
@ -726,7 +724,7 @@ bool FrameEmitterImpl::EmitCompactUnwind(MCStreamer &Streamer,
|
||||
Streamer.SwitchSection(MOFI->getCompactUnwindSection());
|
||||
|
||||
// Range Start
|
||||
unsigned FDEEncoding = TAI.getFDEEncoding(UsingCFI);
|
||||
unsigned FDEEncoding = MOFI->getFDEEncoding(UsingCFI);
|
||||
unsigned Size = getSizeForEncoding(Streamer, FDEEncoding);
|
||||
if (VerboseAsm) Streamer.AddComment("Range Start");
|
||||
Streamer.EmitSymbolValue(Frame.Function, Size);
|
||||
@ -771,7 +769,6 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
|
||||
MCContext &context = streamer.getContext();
|
||||
const MCRegisterInfo &MRI = context.getRegisterInfo();
|
||||
const MCObjectFileInfo *MOFI = context.getObjectFileInfo();
|
||||
const TargetAsmInfo &TAI = context.getTargetAsmInfo();
|
||||
bool verboseAsm = streamer.isVerboseAsm();
|
||||
|
||||
MCSymbol *sectionStart;
|
||||
@ -858,7 +855,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCStreamer &streamer,
|
||||
EmitEncodingByte(streamer, lsdaEncoding, "LSDA Encoding");
|
||||
|
||||
// Encoding of the FDE pointers
|
||||
EmitEncodingByte(streamer, TAI.getFDEEncoding(UsingCFI),
|
||||
EmitEncodingByte(streamer, MOFI->getFDEEncoding(UsingCFI),
|
||||
"FDE Encoding");
|
||||
}
|
||||
|
||||
@ -895,7 +892,6 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer,
|
||||
MCSymbol *fdeStart = context.CreateTempSymbol();
|
||||
MCSymbol *fdeEnd = context.CreateTempSymbol();
|
||||
const MCObjectFileInfo *MOFI = context.getObjectFileInfo();
|
||||
const TargetAsmInfo &TAI = context.getTargetAsmInfo();
|
||||
bool verboseAsm = streamer.isVerboseAsm();
|
||||
|
||||
if (!MOFI->isFunctionEHFrameSymbolPrivate() && IsEH) {
|
||||
@ -927,7 +923,7 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer,
|
||||
streamer.EmitSymbolValue(&cieStart, 4);
|
||||
}
|
||||
|
||||
unsigned fdeEncoding = TAI.getFDEEncoding(UsingCFI);
|
||||
unsigned fdeEncoding = MOFI->getFDEEncoding(UsingCFI);
|
||||
unsigned size = getSizeForEncoding(streamer, fdeEncoding);
|
||||
|
||||
// PC Begin
|
||||
|
@ -21,6 +21,12 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
|
||||
IsFunctionEHFrameSymbolPrivate = false;
|
||||
SupportsWeakOmittedEHFrame = false;
|
||||
|
||||
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel
|
||||
| dwarf::DW_EH_PE_sdata4;
|
||||
LSDAEncoding = FDEEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
|
||||
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
||||
dwarf::DW_EH_PE_sdata4;
|
||||
|
||||
// .comm doesn't support alignment before Leopard.
|
||||
if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
|
||||
CommDirectiveSupportsAlignment = false;
|
||||
@ -199,6 +205,45 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
|
||||
}
|
||||
|
||||
void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
|
||||
if (T.getArch() == Triple::x86) {
|
||||
PersonalityEncoding = (RelocM == Reloc::PIC_)
|
||||
? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
|
||||
: dwarf::DW_EH_PE_absptr;
|
||||
LSDAEncoding = (RelocM == Reloc::PIC_)
|
||||
? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
|
||||
: dwarf::DW_EH_PE_absptr;
|
||||
FDEEncoding = FDECFIEncoding = (RelocM == Reloc::PIC_)
|
||||
? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
|
||||
: dwarf::DW_EH_PE_absptr;
|
||||
TTypeEncoding = (RelocM == Reloc::PIC_)
|
||||
? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
|
||||
: dwarf::DW_EH_PE_absptr;
|
||||
} else if (T.getArch() == Triple::x86_64) {
|
||||
FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
||||
|
||||
if (RelocM == Reloc::PIC_) {
|
||||
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
||||
((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
|
||||
? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
|
||||
LSDAEncoding = dwarf::DW_EH_PE_pcrel |
|
||||
(CMModel == CodeModel::Small
|
||||
? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
|
||||
FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
|
||||
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
|
||||
((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
|
||||
? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
|
||||
} else {
|
||||
PersonalityEncoding =
|
||||
(CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
|
||||
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
|
||||
LSDAEncoding = (CMModel == CodeModel::Small)
|
||||
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
|
||||
FDEEncoding = dwarf::DW_EH_PE_udata4;
|
||||
TTypeEncoding = (CMModel == CodeModel::Small)
|
||||
? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
|
||||
}
|
||||
}
|
||||
|
||||
// ELF
|
||||
BSSSection =
|
||||
Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
|
||||
@ -446,15 +491,21 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
|
||||
}
|
||||
|
||||
void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
|
||||
CodeModel::Model cm,
|
||||
MCContext &ctx) {
|
||||
RelocM = relocm;
|
||||
CMModel = cm;
|
||||
Ctx = &ctx;
|
||||
|
||||
// Common.
|
||||
CommDirectiveSupportsAlignment = true;
|
||||
SupportsWeakOmittedEHFrame = true;
|
||||
IsFunctionEHFrameSymbolPrivate = true;
|
||||
EHFrameSection = 0;
|
||||
|
||||
PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding =
|
||||
TTypeEncoding = dwarf::DW_EH_PE_absptr;
|
||||
|
||||
EHFrameSection = 0; // Created on demand.
|
||||
|
||||
Triple T(TT);
|
||||
Triple::ArchType Arch = T.getArch();
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetAsmParser.h"
|
||||
#include <cctype>
|
||||
#include <vector>
|
||||
|
@ -1676,7 +1676,7 @@ bool CWriter::doInitialization(Module &M) {
|
||||
#endif
|
||||
TAsm = new CBEMCAsmInfo();
|
||||
MRI = new MCRegisterInfo();
|
||||
TCtx = new MCContext(*TAsm, *MRI, NULL, NULL);
|
||||
TCtx = new MCContext(*TAsm, *MRI, NULL);
|
||||
Mang = new Mangler(*TCtx, *TD);
|
||||
|
||||
// Keep track of which functions are static ctors/dtors so they can have
|
||||
|
@ -1,18 +0,0 @@
|
||||
//===-- llvm/Target/TargetAsmInfo.cpp - Target Assembly Info --------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Target/TargetAsmInfo.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
using namespace llvm;
|
||||
|
||||
TargetAsmInfo::TargetAsmInfo(const TargetMachine &TM) {
|
||||
TLOF = &TM.getTargetLowering()->getObjFileLowering();
|
||||
}
|
@ -41,7 +41,8 @@ using namespace llvm;
|
||||
void TargetLoweringObjectFile::Initialize(MCContext &ctx,
|
||||
const TargetMachine &TM) {
|
||||
Ctx = &ctx;
|
||||
InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(), *Ctx);
|
||||
InitMCObjectFileInfo(TM.getTargetTriple(),
|
||||
TM.getRelocationModel(), TM.getCodeModel(), *Ctx);
|
||||
}
|
||||
|
||||
TargetLoweringObjectFile::~TargetLoweringObjectFile() {
|
||||
@ -322,20 +323,3 @@ getExprForDwarfReference(const MCSymbol *Sym, unsigned Encoding,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFile::getPersonalityEncoding() const {
|
||||
return dwarf::DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFile::getLSDAEncoding() const {
|
||||
return dwarf::DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFile::getFDEEncoding(bool CFI) const {
|
||||
return dwarf::DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned TargetLoweringObjectFile::getTTypeEncoding() const {
|
||||
return dwarf::DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
|
@ -197,11 +197,8 @@ static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
|
||||
return new TargetLoweringObjectFileMachO();
|
||||
}
|
||||
|
||||
if (Subtarget->isTargetELF()) {
|
||||
if (is64Bit)
|
||||
return new X8664_ELFTargetObjectFile(TM);
|
||||
return new X8632_ELFTargetObjectFile(TM);
|
||||
}
|
||||
if (Subtarget->isTargetELF())
|
||||
return new TargetLoweringObjectFileELF();
|
||||
if (Subtarget->isTargetCOFF() && !Subtarget->isTargetEnvMacho())
|
||||
return new TargetLoweringObjectFileCOFF();
|
||||
llvm_unreachable("unknown subtarget type");
|
||||
|
@ -43,79 +43,3 @@ getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
|
||||
MachineModuleInfo *MMI) const {
|
||||
return Mang->getSymbol(GV);
|
||||
}
|
||||
|
||||
unsigned X8632_ELFTargetObjectFile::getPersonalityEncoding() const {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
else
|
||||
return DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned X8632_ELFTargetObjectFile::getLSDAEncoding() const {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
else
|
||||
return DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned X8632_ELFTargetObjectFile::getFDEEncoding(bool FDE) const {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
else
|
||||
return DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned X8632_ELFTargetObjectFile::getTTypeEncoding() const {
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
else
|
||||
return DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned X8664_ELFTargetObjectFile::getPersonalityEncoding() const {
|
||||
CodeModel::Model Model = TM.getCodeModel();
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_indirect | DW_EH_PE_pcrel | (Model == CodeModel::Small ||
|
||||
Model == CodeModel::Medium ?
|
||||
DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
|
||||
|
||||
if (Model == CodeModel::Small || Model == CodeModel::Medium)
|
||||
return DW_EH_PE_udata4;
|
||||
|
||||
return DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned X8664_ELFTargetObjectFile::getLSDAEncoding() const {
|
||||
CodeModel::Model Model = TM.getCodeModel();
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_pcrel | (Model == CodeModel::Small ?
|
||||
DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
|
||||
|
||||
if (Model == CodeModel::Small)
|
||||
return DW_EH_PE_udata4;
|
||||
|
||||
return DW_EH_PE_absptr;
|
||||
}
|
||||
|
||||
unsigned X8664_ELFTargetObjectFile::getFDEEncoding(bool CFI) const {
|
||||
if (CFI)
|
||||
return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
|
||||
|
||||
return DW_EH_PE_udata4;
|
||||
}
|
||||
|
||||
unsigned X8664_ELFTargetObjectFile::getTTypeEncoding() const {
|
||||
CodeModel::Model Model = TM.getCodeModel();
|
||||
if (TM.getRelocationModel() == Reloc::PIC_)
|
||||
return DW_EH_PE_indirect | DW_EH_PE_pcrel | (Model == CodeModel::Small ||
|
||||
Model == CodeModel::Medium ?
|
||||
DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
|
||||
|
||||
if (Model == CodeModel::Small)
|
||||
return DW_EH_PE_udata4;
|
||||
|
||||
return DW_EH_PE_absptr;
|
||||
}
|
||||
|
@ -33,28 +33,6 @@ namespace llvm {
|
||||
MachineModuleInfo *MMI) const;
|
||||
};
|
||||
|
||||
class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF {
|
||||
const X86TargetMachine &TM;
|
||||
public:
|
||||
X8632_ELFTargetObjectFile(const X86TargetMachine &tm)
|
||||
:TM(tm) { }
|
||||
virtual unsigned getPersonalityEncoding() const;
|
||||
virtual unsigned getLSDAEncoding() const;
|
||||
virtual unsigned getFDEEncoding(bool CFI) const;
|
||||
virtual unsigned getTTypeEncoding() const;
|
||||
};
|
||||
|
||||
class X8664_ELFTargetObjectFile : public TargetLoweringObjectFileELF {
|
||||
const X86TargetMachine &TM;
|
||||
public:
|
||||
X8664_ELFTargetObjectFile(const X86TargetMachine &tm)
|
||||
:TM(tm) { }
|
||||
virtual unsigned getPersonalityEncoding() const;
|
||||
virtual unsigned getLSDAEncoding() const;
|
||||
virtual unsigned getFDEEncoding(bool CFI) const;
|
||||
virtual unsigned getTTypeEncoding() const;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
@ -28,10 +28,6 @@
|
||||
#include "llvm/Target/TargetAsmParser.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
#include "llvm/Target/TargetAsmInfo.h" // FIXME.
|
||||
#include "llvm/Target/TargetLowering.h" // FIXME.
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h" // FIXME.
|
||||
#include "llvm/Target/TargetMachine.h" // FIXME.
|
||||
#include "llvm/Target/TargetSelect.h"
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
@ -348,28 +344,11 @@ static int AssembleInput(const char *ProgName) {
|
||||
// Package up features to be passed to target/subtarget
|
||||
std::string FeaturesStr;
|
||||
|
||||
// FIXME: We shouldn't need to do this (and link in codegen).
|
||||
// When we split this out, we should do it in a way that makes
|
||||
// it straightforward to switch subtargets on the fly (.e.g,
|
||||
// the .cpu and .code16 directives).
|
||||
OwningPtr<TargetMachine> TM(TheTarget->createTargetMachine(TripleName,
|
||||
MCPU,
|
||||
FeaturesStr,
|
||||
RelocModel,
|
||||
CMModel));
|
||||
|
||||
if (!TM) {
|
||||
errs() << ProgName << ": error: could not create target for triple '"
|
||||
<< TripleName << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
const TargetAsmInfo *tai = new TargetAsmInfo(*TM);
|
||||
// FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
|
||||
// MCObjectFileInfo needs a MCContext reference in order to initialize itself.
|
||||
OwningPtr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
|
||||
MCContext Ctx(*MAI, *MRI, MOFI.get(), tai);
|
||||
MOFI->InitMCObjectFileInfo(TripleName, RelocModel, Ctx);
|
||||
MCContext Ctx(*MAI, *MRI, MOFI.get());
|
||||
MOFI->InitMCObjectFileInfo(TripleName, RelocModel, CMModel, Ctx);
|
||||
|
||||
if (SaveTempLabels)
|
||||
Ctx.setAllowTemporaryLabels(false);
|
||||
@ -381,10 +360,6 @@ static int AssembleInput(const char *ProgName) {
|
||||
formatted_raw_ostream FOS(Out->os());
|
||||
OwningPtr<MCStreamer> Str;
|
||||
|
||||
const TargetLoweringObjectFile &TLOF =
|
||||
TM->getTargetLowering()->getObjFileLowering();
|
||||
const_cast<TargetLoweringObjectFile&>(TLOF).Initialize(Ctx, *TM);
|
||||
|
||||
OwningPtr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo());
|
||||
OwningPtr<MCSubtargetInfo>
|
||||
STI(TheTarget->createMCSubtargetInfo(TripleName, MCPU, FeaturesStr));
|
||||
|
@ -313,8 +313,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
|
||||
passes.add(createVerifierPass());
|
||||
|
||||
// mark which symbols can not be internalized
|
||||
MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),
|
||||
NULL, NULL);
|
||||
MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(), NULL);
|
||||
Mangler mangler(Context, *_target->getTargetData());
|
||||
std::vector<const char*> mustPreserveList;
|
||||
SmallPtrSet<GlobalValue*, 8> asmUsed;
|
||||
|
@ -664,8 +664,7 @@ static bool isAliasToDeclaration(const GlobalAlias &V) {
|
||||
|
||||
bool LTOModule::ParseSymbols() {
|
||||
// Use mangler to add GlobalPrefix to names to match linker names.
|
||||
MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),
|
||||
NULL, NULL);
|
||||
MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),NULL);
|
||||
Mangler mangler(Context, *_target->getTargetData());
|
||||
|
||||
// add functions
|
||||
|
Loading…
Reference in New Issue
Block a user