``a<size>:<abi>:<pref>``
This specifies the alignment for an aggregate type of a given bit
``<size>``.
+``m:<mangling>``
+ If prerest, specifies that llvm names are mangled in the output. The
+ options are
+ * ``e``: ELF mangling: Private symbols get a ``.L`` prefix.
+ * ``m``: Mips mangling: Private symbols get a ``$`` prefix.
+ * ``o``: Mach-O mangling: Private symbols get ``L`` prefix. Other
+ symbols get a ``_`` prefix.
+ * ``c``: COFF prefix: Similar to Mach-O, but stdcall and fastcall
+ functions also get a sufiix based on the frame size.
``n<size1>:<size2>:<size3>...``
This specifies a set of native integer widths for the target CPU in
bits. For example, it might contain ``n32`` for 32-bit PowerPC,
class IntegerType;
class StructType;
class StructLayout;
+class Triple;
class GlobalVariable;
class LLVMContext;
template<typename T>
bool LittleEndian; ///< Defaults to false
unsigned StackNaturalAlign; ///< Stack natural alignment
+ enum ManglingModeT {
+ MM_None,
+ MM_ELF,
+ MM_MachO,
+ MM_COFF,
+ MM_Mips
+ };
+ ManglingModeT ManglingMode;
+
SmallVector<unsigned char, 8> LegalIntWidths; ///< Legal Integers.
/// Alignments - Where the primitive type alignment data is stored.
ImmutablePass(ID),
LittleEndian(DL.isLittleEndian()),
StackNaturalAlign(DL.StackNaturalAlign),
+ ManglingMode(DL.ManglingMode),
LegalIntWidths(DL.LegalIntWidths),
Alignments(DL.Alignments),
Pointers(DL.Pointers),
return (StackNaturalAlign != 0) && (Align > StackNaturalAlign);
}
+ bool hasMicrosoftFastStdCallMangling() const {
+ return ManglingMode == MM_COFF;
+ }
+
+ bool hasLinkerPrivateGlobalPrefix() const {
+ return ManglingMode == MM_MachO;
+ }
+
+ const char *getLinkerPrivateGlobalPrefix() const {
+ if (ManglingMode == MM_MachO)
+ return "l";
+ return getPrivateGlobalPrefix();
+ }
+
+ char getGlobalPrefix() const {
+ switch (ManglingMode) {
+ case MM_None:
+ case MM_ELF:
+ case MM_Mips:
+ return '\0';
+ case MM_MachO:
+ case MM_COFF:
+ return '_';
+ }
+ }
+
+ const char *getPrivateGlobalPrefix() const {
+ switch (ManglingMode) {
+ case MM_None:
+ return "";
+ case MM_ELF:
+ return ".L";
+ case MM_Mips:
+ return "$";
+ case MM_MachO:
+ case MM_COFF:
+ return "L";
+ }
+ }
+
+ static const char *getManglingComponent(const Triple &T);
+
/// fitsInLegalInteger - This function returns true if the specified type fits
/// in a native integer type supported by the CPU. For example, if the CPU
/// only supports i32 as a native integer type, then i27 fits in a legal
/// LabelSuffix - This is appended to emitted labels.
const char *DebugLabelSuffix; // Defaults to ":"
- /// If this is set to anything other than '\0', it is prepended
- /// onto all global symbols. This is often used for '_'.
- char GlobalPrefix; // Defaults to '\0'
-
/// This prefix is used for globals like constant pool entries that are
/// completely private to the .s file and should not have names in the .o
/// file.
const char *PrivateGlobalPrefix; // Defaults to "L"
- /// This prefix is used for symbols that should be passed through the
- /// assembler but be removed by the linker. This is 'l' on Darwin,
- /// currently used for some ObjC metadata.
- /// The default of "" meast that for this system a plain private symbol
- /// should be used.
- const char *LinkerPrivateGlobalPrefix; // Defaults to "".
-
/// InlineAsmStart/End - If these are nonempty, they contain a directive to
/// emit before and after an inline assembly statement.
const char *InlineAsmStart; // Defaults to "#APP\n"
/// which doesn't support the '.bss' directive only.
bool UsesELFSectionDirectiveForBSS; // Defaults to false.
- /// HasMicrosoftFastStdCallMangling - True if this target uses microsoft
- /// style mangling for functions with X86_StdCall/X86_FastCall calling
- /// convention.
- bool HasMicrosoftFastStdCallMangling; // Defaults to false.
-
bool NeedsDwarfSectionOffsetDirective;
//===--- Alignment Information ----------------------------------------===//
return UsesELFSectionDirectiveForBSS;
}
- bool hasMicrosoftFastStdCallMangling() const {
- return HasMicrosoftFastStdCallMangling;
- }
-
bool needsDwarfSectionOffsetDirective() const {
return NeedsDwarfSectionOffsetDirective;
}
const char *getDebugLabelSuffix() const {
return DebugLabelSuffix;
}
-
- char getGlobalPrefix() const {
- return GlobalPrefix;
- }
const char *getPrivateGlobalPrefix() const {
return PrivateGlobalPrefix;
}
- bool hasLinkerPrivateGlobalPrefix() const {
- return LinkerPrivateGlobalPrefix[0] != '\0';
- }
- const char *getLinkerPrivateGlobalPrefix() const {
- if (hasLinkerPrivateGlobalPrefix())
- return LinkerPrivateGlobalPrefix;
- return getPrivateGlobalPrefix();
- }
const char *getInlineAsmStart() const {
return InlineAsmStart;
}
namespace llvm {
+class DataLayout;
class GlobalValue;
class MCContext;
template <typename T> class SmallVectorImpl;
-class TargetMachine;
class Twine;
class Mangler {
};
private:
- const TargetMachine *TM;
+ const DataLayout *DL;
/// AnonGlobalIDs - We need to give global values the same name every time
/// they are mangled. This keeps track of the number we give to anonymous
unsigned NextAnonGlobalID;
public:
- Mangler(const TargetMachine *TM) : TM(TM), NextAnonGlobalID(1) {}
+ Mangler(const DataLayout *DL) : DL(DL), NextAnonGlobalID(1) {}
/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
/// and the specified global variable's name. If the global variable doesn't
class TargetLoweringObjectFile : public MCObjectFileInfo {
MCContext *Ctx;
+ const DataLayout *DL;
TargetLoweringObjectFile(
const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
public:
MCContext &getContext() const { return *Ctx; }
- TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(0) {}
+ TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(0), DL(0) {}
virtual ~TargetLoweringObjectFile();
OutStreamer.InitStreamer();
- Mang = new Mangler(&TM);
+ Mang = new Mangler(TM.getDataLayout());
// Allow the target to emit any magic that it wants at the start of the file.
EmitStartOfAsmFile(M);
/// by the current function to the current output stream.
///
void AsmPrinter::EmitJumpTableInfo() {
+ const DataLayout *DL = MF->getTarget().getDataLayout();
const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
if (MJTI == 0) return;
if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_Inline) return;
// before each jump table. The first label is never referenced, but tells
// the assembler and linker the extents of the jump table object. The
// second label is actually referenced by the code.
- if (JTInDiffSection && MAI->hasLinkerPrivateGlobalPrefix())
+ if (JTInDiffSection && DL->hasLinkerPrivateGlobalPrefix())
// FIXME: This doesn't have to have any specific name, just any randomly
// named and numbered 'l' label would work. Simplify GetJTISymbol.
OutStreamer.EmitLabel(GetJTISymbol(JTI, true));
/// GetTempSymbol - Return the MCSymbol corresponding to the assembler
/// temporary label with the specified stem and unique ID.
MCSymbol *AsmPrinter::GetTempSymbol(StringRef Name, unsigned ID) const {
- return OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
+ const DataLayout *DL = TM.getDataLayout();
+ return OutContext.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix()) +
Name + Twine(ID));
}
/// GetTempSymbol - Return an assembler temporary label with the specified
/// stem.
MCSymbol *AsmPrinter::GetTempSymbol(StringRef Name) const {
- return OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix())+
+ const DataLayout *DL = TM.getDataLayout();
+ return OutContext.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix())+
Name);
}
/// GetCPISymbol - Return the symbol for the specified constant pool entry.
MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const {
+ const DataLayout *DL = TM.getDataLayout();
return OutContext.GetOrCreateSymbol
- (Twine(MAI->getPrivateGlobalPrefix()) + "CPI" + Twine(getFunctionNumber())
+ (Twine(DL->getPrivateGlobalPrefix()) + "CPI" + Twine(getFunctionNumber())
+ "_" + Twine(CPID));
}
/// GetJTSetSymbol - Return the symbol for the specified jump table .set
/// FIXME: privatize to AsmPrinter.
MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const {
+ const DataLayout *DL = TM.getDataLayout();
return OutContext.GetOrCreateSymbol
- (Twine(MAI->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) + "_" +
+ (Twine(DL->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) + "_" +
Twine(UID) + "_set_" + Twine(MBBID));
}
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
/// for their own strange codes.
void AsmPrinter::PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
const char *Code) const {
+ const DataLayout *DL = TM.getDataLayout();
if (!strcmp(Code, "private")) {
- OS << MAI->getPrivateGlobalPrefix();
+ OS << DL->getPrivateGlobalPrefix();
} else if (!strcmp(Code, "comment")) {
OS << MAI->getCommentString();
} else if (!strcmp(Code, "uid")) {
if (!CachedMCSymbol) {
const MachineFunction *MF = getParent();
MCContext &Ctx = MF->getContext();
- const char *Prefix = Ctx.getAsmInfo()->getPrivateGlobalPrefix();
+ const TargetMachine &TM = MF->getTarget();
+ const char *Prefix = TM.getDataLayout()->getPrivateGlobalPrefix();
CachedMCSymbol = Ctx.GetOrCreateSymbol(Twine(Prefix) + "BB" +
Twine(MF->getFunctionNumber()) +
"_" + Twine(getNumber()));
/// normal 'L' label is returned.
MCSymbol *MachineFunction::getJTISymbol(unsigned JTI, MCContext &Ctx,
bool isLinkerPrivate) const {
+ const DataLayout *DL = getTarget().getDataLayout();
assert(JumpTableInfo && "No jump tables");
assert(JTI < JumpTableInfo->getJumpTables().size() && "Invalid JTI!");
- const MCAsmInfo &MAI = *getTarget().getMCAsmInfo();
- const char *Prefix = isLinkerPrivate ? MAI.getLinkerPrivateGlobalPrefix() :
- MAI.getPrivateGlobalPrefix();
+ const char *Prefix = isLinkerPrivate ? DL->getLinkerPrivateGlobalPrefix() :
+ DL->getPrivateGlobalPrefix();
SmallString<60> Name;
raw_svector_ostream(Name)
<< Prefix << "JTI" << getFunctionNumber() << '_' << JTI;
/// getPICBaseSymbol - Return a function-local symbol to represent the PIC
/// base.
MCSymbol *MachineFunction::getPICBaseSymbol() const {
- const MCAsmInfo &MAI = *Target.getMCAsmInfo();
- return Ctx.GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix())+
+ const DataLayout *DL = getTarget().getDataLayout();
+ return Ctx.GetOrCreateSymbol(Twine(DL->getPrivateGlobalPrefix())+
Twine(getFunctionNumber())+"$pb");
}
}
uint64_t MCJIT::getExistingSymbolAddress(const std::string &Name) {
- Mangler Mang(TM);
+ Mangler Mang(TM->getDataLayout());
SmallString<128> FullName;
Mang.getNameWithPrefix(FullName, Name);
return Dyld.getSymbolLoadAddress(FullName);
//
// This is the accessor for the target address, so make sure to check the
// load address of the symbol, not the local address.
- Mangler Mang(TM);
+ Mangler Mang(TM->getDataLayout());
SmallString<128> Name;
Mang.getNameWithPrefix(Name, F);
return (void*)Dyld.getSymbolLoadAddress(Name);
#include "llvm/IR/DataLayout.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Module.h"
// DataLayout Class Implementation
//===----------------------------------------------------------------------===//
+const char *DataLayout::getManglingComponent(const Triple &T) {
+ if (T.isOSBinFormatMachO())
+ return "-m:o";
+ if (T.isOSBinFormatELF() || T.isArch64Bit())
+ return "-m:e";
+ assert(T.isOSBinFormatCOFF());
+ return "-m:c";
+}
+
static const LayoutAlignElem DefaultAlignments[] = {
{ INTEGER_ALIGN, 1, 1, 1 }, // i1
{ INTEGER_ALIGN, 8, 1, 1 }, // i8
LayoutMap = 0;
LittleEndian = false;
StackNaturalAlign = 0;
+ ManglingMode = MM_None;
// Default alignments
for (int I = 0, N = array_lengthof(DefaultAlignments); I < N; ++I) {
StackNaturalAlign = inBytes(getInt(Tok));
break;
}
+ case 'm':
+ assert(Tok.empty());
+ assert(Rest.size() == 1);
+ switch(Rest[0]) {
+ default:
+ llvm_unreachable("Unknown mangling in datalayout string");
+ case 'e':
+ ManglingMode = MM_ELF;
+ break;
+ case 'o':
+ ManglingMode = MM_MachO;
+ break;
+ case 'm':
+ ManglingMode = MM_Mips;
+ break;
+ case 'c':
+ ManglingMode = MM_COFF;
+ break;
+ }
+ break;
default:
llvm_unreachable("Unknown specifier in datalayout string");
break;
raw_string_ostream OS(Result);
OS << (LittleEndian ? "e" : "E");
+
+ switch (ManglingMode) {
+ case MM_None:
+ break;
+ case MM_ELF:
+ OS << "-m:e";
+ break;
+ case MM_MachO:
+ OS << "-m:o";
+ break;
+ case MM_COFF:
+ OS << "-m:c";
+ break;
+ case MM_Mips:
+ OS << "-m:m";
+ break;
+ }
+
SmallVector<unsigned, 8> addrSpaces;
// Lets get all of the known address spaces and sort them
// into increasing order so that we can emit the string
passes.add(createVerifierPass());
// mark which symbols can not be internalized
- Mangler Mangler(TargetMach);
+ Mangler Mangler(TargetMach->getDataLayout());
std::vector<const char*> MustPreserveList;
SmallPtrSet<GlobalValue*, 8> AsmUsed;
std::vector<StringRef> Libcalls;
LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t)
: _module(m), _target(t),
_context(_target->getMCAsmInfo(), _target->getRegisterInfo(), &ObjFileInfo),
- _mangler(t) {
+ _mangler(t->getDataLayout()) {
ObjFileInfo.InitMCObjectFileInfo(t->getTargetTriple(),
t->getRelocationModel(), t->getCodeModel(),
_context);
CommentString = "#";
LabelSuffix = ":";
DebugLabelSuffix = ":";
- GlobalPrefix = '\0';
PrivateGlobalPrefix = "L";
- LinkerPrivateGlobalPrefix = "";
InlineAsmStart = "APP";
InlineAsmEnd = "NO_APP";
Code16Directive = ".code16";
ExceptionsType = ExceptionHandling::None;
DwarfUsesRelocationsAcrossSections = true;
DwarfRegNumForCFI = false;
- HasMicrosoftFastStdCallMangling = false;
NeedsDwarfSectionOffsetDirective = false;
UseParensForSymbolVariant = false;
}
void MCAsmInfoCOFF::anchor() { }
MCAsmInfoCOFF::MCAsmInfoCOFF() {
- GlobalPrefix = '_';
// MingW 4.5 and later support .comm with log2 alignment, but .lcomm uses byte
// alignment.
COMMDirectiveAlignmentIsInBytes = false;
// Set up DWARF directives
HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
SupportsDebugInformation = true;
- HasMicrosoftFastStdCallMangling = true;
NeedsDwarfSectionOffsetDirective = true;
}
MCAsmInfoDarwin::MCAsmInfoDarwin() {
// Common settings for all Darwin targets.
// Syntax:
- GlobalPrefix = '_';
- LinkerPrivateGlobalPrefix = "l";
HasSingleParameterDotFile = false;
HasSubsectionsViaSymbols = true;
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
Subtarget(TT, CPU, FS),
InstrInfo(Subtarget),
- DL("e-i64:64-i128:128-n32:64-S128"),
+ DL("e-m:e-i64:64-i128:128-n32:64-S128"),
TLInfo(*this),
TSInfo(*this),
FrameLowering(Subtarget) {
MCSymbol *ARMAsmPrinter::
GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const {
+ const DataLayout *DL = TM.getDataLayout();
SmallString<60> Name;
- raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "JTI"
+ raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "JTI"
<< getFunctionNumber() << '_' << uid << '_' << uid2;
return OutContext.GetOrCreateSymbol(Name.str());
}
MCSymbol *ARMAsmPrinter::GetARMSJLJEHLabel() const {
+ const DataLayout *DL = TM.getDataLayout();
SmallString<60> Name;
- raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "SJLJEH"
+ raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "SJLJEH"
<< getFunctionNumber();
return OutContext.GetOrCreateSymbol(Name.str());
}
void ARMAsmPrinter::
EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
+ const DataLayout *DL = TM.getDataLayout();
int Size = TM.getDataLayout()->getTypeAllocSize(MCPV->getType());
ARMConstantPoolValue *ACPV = static_cast<ARMConstantPoolValue*>(MCPV);
if (ACPV->isLSDA()) {
SmallString<128> Str;
raw_svector_ostream OS(Str);
- OS << MAI->getPrivateGlobalPrefix() << "_LSDA_" << getFunctionNumber();
+ OS << DL->getPrivateGlobalPrefix() << "_LSDA_" << getFunctionNumber();
MCSym = OutContext.GetOrCreateSymbol(OS.str());
} else if (ACPV->isBlockAddress()) {
const BlockAddress *BA =
OutContext);
if (ACPV->getPCAdjustment()) {
- MCSymbol *PCLabel = getPICLabel(MAI->getPrivateGlobalPrefix(),
+ MCSymbol *PCLabel = getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(),
ACPV->getLabelId(),
OutContext);
#include "ARMGenMCPseudoLowering.inc"
void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
+ const DataLayout *DL = TM.getDataLayout();
+
// If we just ended a constant pool, mark it as such.
if (InConstantPool && MI->getOpcode() != ARM::CONSTPOOL_ENTRY) {
OutStreamer.EmitDataRegion(MCDR_DataRegionEnd);
MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
const MCExpr *GVSymExpr = MCSymbolRefExpr::Create(GVSym, OutContext);
- MCSymbol *LabelSym = getPICLabel(MAI->getPrivateGlobalPrefix(),
+ MCSymbol *LabelSym = getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(),
MI->getOperand(2).getImm(), OutContext);
const MCExpr *LabelSymExpr= MCSymbolRefExpr::Create(LabelSym, OutContext);
MCSymbol *GVSym = GetARMGVSymbol(GV, TF);
const MCExpr *GVSymExpr = MCSymbolRefExpr::Create(GVSym, OutContext);
- MCSymbol *LabelSym = getPICLabel(MAI->getPrivateGlobalPrefix(),
+ MCSymbol *LabelSym = getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(),
MI->getOperand(3).getImm(), OutContext);
const MCExpr *LabelSymExpr= MCSymbolRefExpr::Create(LabelSym, OutContext);
// This adds the address of LPC0 to r0.
// Emit the label.
- OutStreamer.EmitLabel(getPICLabel(MAI->getPrivateGlobalPrefix(),
+ OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(), MI->getOperand(2).getImm(),
OutContext));
// This adds the address of LPC0 to r0.
// Emit the label.
- OutStreamer.EmitLabel(getPICLabel(MAI->getPrivateGlobalPrefix(),
+ OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(), MI->getOperand(2).getImm(),
OutContext));
// a PC-relative address at the ldr instruction.
// Emit the label.
- OutStreamer.EmitLabel(getPICLabel(MAI->getPrivateGlobalPrefix(),
+ OutStreamer.EmitLabel(getPICLabel(DL->getPrivateGlobalPrefix(),
getFunctionNumber(), MI->getOperand(2).getImm(),
OutContext));
void ARMTargetMachine::anchor() { }
static std::string computeDataLayout(ARMSubtarget &ST) {
- // Little endian. Pointers are 32 bits and aligned to 32 bits.
- std::string Ret = "e-p:32:32";
+ // Little endian.
+ std::string Ret = "e";
+
+ Ret += DataLayout::getManglingComponent(ST.getTargetTriple());
+
+ // Pointers are 32 bits and aligned to 32 bits.
+ Ret += "-p:32:32";
// On thumb, i16,i18 and i1 have natural aligment requirements, but we try to
// align to 32.
CodeModel::Model CM,
CodeGenOpt::Level OL)
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
- DL("e-p:32:32-i1:32-i64:64-a:0-n32") ,
+ DL("e-m:e-p:32:32-i1:32-i64:64-a:0-n32") ,
Subtarget(TT, CPU, FS), InstrInfo(Subtarget), TLInfo(*this),
TSInfo(*this),
FrameLowering(Subtarget),
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/IR/DataLayout.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/Mangler.h"
+#include "llvm/Target/TargetMachine.h"
using namespace llvm;
MCSymbol *MSP430MCInstLower::
MCSymbol *MSP430MCInstLower::
GetJumpTableSymbol(const MachineOperand &MO) const {
+ const DataLayout *DL = Printer.TM.getDataLayout();
SmallString<256> Name;
- raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "JTI"
+ raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "JTI"
<< Printer.getFunctionNumber() << '_'
<< MO.getIndex();
MCSymbol *MSP430MCInstLower::
GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
+ const DataLayout *DL = Printer.TM.getDataLayout();
SmallString<256> Name;
- raw_svector_ostream(Name) << Printer.MAI->getPrivateGlobalPrefix() << "CPI"
+ raw_svector_ostream(Name) << DL->getPrivateGlobalPrefix() << "CPI"
<< Printer.getFunctionNumber() << '_'
<< MO.getIndex();
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
Subtarget(TT, CPU, FS),
// FIXME: Check DataLayout string.
- DL("e-p:16:16-i32:16:32-n8:16"),
+ DL("e-m:e-p:16:16-i32:16:32-n8:16"),
InstrInfo(*this), TLInfo(*this), TSInfo(*this),
FrameLowering(Subtarget) {
initAsmInfo();
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
-#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
-#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
SmallString<256> TmpData;
StringRef Name = GVName.toStringRef(TmpData);
assert(!Name.empty() && "getNameWithPrefix requires non-empty name");
-
- const MCAsmInfo *MAI = TM->getMCAsmInfo();
-
+
// If the global name is not led with \1, add the appropriate prefixes.
if (Name[0] == '\1') {
Name = Name.substr(1);
} else {
if (PrefixTy == Mangler::Private) {
- const char *Prefix = MAI->getPrivateGlobalPrefix();
+ const char *Prefix = DL->getPrivateGlobalPrefix();
OutName.append(Prefix, Prefix+strlen(Prefix));
} else if (PrefixTy == Mangler::LinkerPrivate) {
- const char *Prefix = MAI->getLinkerPrivateGlobalPrefix();
+ const char *Prefix = DL->getLinkerPrivateGlobalPrefix();
OutName.append(Prefix, Prefix+strlen(Prefix));
}
-
- char Prefix = MAI->getGlobalPrefix();
+ char Prefix = DL->getGlobalPrefix();
if (Prefix != '\0')
OutName.push_back(Prefix);
}
// Must mangle the global into a unique ID.
getNameWithPrefix(OutName, "__unnamed_" + Twine(ID), PrefixTy);
}
-
+
// If we are supposed to add a microsoft-style suffix for stdcall/fastcall,
// add it.
- if (TM->getMCAsmInfo()->hasMicrosoftFastStdCallMangling()) {
+ if (DL->hasMicrosoftFastStdCallMangling()) {
if (const Function *F = dyn_cast<Function>(GV)) {
CallingConv::ID CC = F->getCallingConv();
// "Pure" variadic functions do not receive @0 suffix.
(!FT->isVarArg() || FT->getNumParams() == 0 ||
(FT->getNumParams() == 1 && F->hasStructRetAttr())))
- AddFastCallStdCallSuffix(OutName, F, *TM->getDataLayout());
+ AddFastCallStdCallSuffix(OutName, F, *DL);
}
}
}
void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
raw_ostream &O) {
+ const DataLayout *DL = TM.getDataLayout();
const MachineOperand &MO = MI->getOperand(opNum);
bool closeP = false;
}
case MachineOperand::MO_ConstantPoolIndex:
- O << MAI->getPrivateGlobalPrefix() << "CPI"
+ O << DL->getPrivateGlobalPrefix() << "CPI"
<< getFunctionNumber() << "_" << MO.getIndex();
if (MO.getOffset())
O << "+" << MO.getOffset();
else
Ret += "E";
+ Ret += "-m:m";
+
// Pointers are 32 bit on some ABIs.
if (!ST.isABI_N64())
Ret += "-p:32:32";
const_cast<TargetLoweringObjectFile &>(getObjFileLowering())
.Initialize(OutContext, TM);
- Mang = new Mangler(&TM);
+ Mang = new Mangler(TM.getDataLayout());
// Emit header before any dwarf directives are emitted below.
emitHeader(M, OS1);
void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
raw_ostream &O) {
+ const DataLayout *DL = TM.getDataLayout();
const MachineOperand &MO = MI->getOperand(OpNo);
switch (MO.getType()) {
O << *MO.getMBB()->getSymbol();
return;
case MachineOperand::MO_ConstantPoolIndex:
- O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
+ O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
<< '_' << MO.getIndex();
return;
case MachineOperand::MO_BlockAddress:
/// exists for it. If not, create one. Then return a symbol that references
/// the TOC entry.
MCSymbol *PPCAsmPrinter::lookUpOrCreateTOCEntry(MCSymbol *Sym) {
-
+ const DataLayout *DL = TM.getDataLayout();
MCSymbol *&TOCEntry = TOC[Sym];
// To avoid name clash check if the name already exists.
while (TOCEntry == 0) {
- if (OutContext.LookupSymbol(Twine(MAI->getPrivateGlobalPrefix()) +
+ if (OutContext.LookupSymbol(Twine(DL->getPrivateGlobalPrefix()) +
"C" + Twine(TOCLabelID++)) == 0) {
TOCEntry = GetTempSymbol("C", TOCLabelID);
}
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
+#include "llvm/IR/DataLayout.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/Target/Mangler.h"
+#include "llvm/Target/TargetMachine.h"
using namespace llvm;
static MachineModuleInfoMachO &getMachOMMI(AsmPrinter &AP) {
static MCSymbol *GetSymbolFromOperand(const MachineOperand &MO, AsmPrinter &AP){
+ const DataLayout *DL = AP.TM.getDataLayout();
MCContext &Ctx = AP.OutContext;
SmallString<128> Name;
Suffix = "$non_lazy_ptr";
if (!Suffix.empty())
- Name += AP.MAI->getPrivateGlobalPrefix();
+ Name += DL->getPrivateGlobalPrefix();
unsigned PrefixLen = Name.size();
// PPC is big endian.
std::string Ret = "E";
+ Ret += DataLayout::getManglingComponent(T);
+
// PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
// pointers.
if (!ST.isPPC64() || T.getOS() == Triple::Lv2)
void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
raw_ostream &O) {
+ const DataLayout *DL = TM.getDataLayout();
const MachineOperand &MO = MI->getOperand (opNum);
unsigned TF = MO.getTargetFlags();
#ifndef NDEBUG
O << MO.getSymbolName();
break;
case MachineOperand::MO_ConstantPoolIndex:
- O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
+ O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
<< MO.getIndex();
break;
default:
static std::string computeDataLayout(const SparcSubtarget &ST) {
// Sparc is big endian.
- std::string Ret = "E";
+ std::string Ret = "E-m:e";
// Some ABIs have 32bit pointers.
if (!ST.is64Bit())
// Make sure that global data has at least 16 bits of alignment by default,
// so that we can refer to it using LARL. We don't have any special
// requirements for stack variables though.
- DL("E-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"),
+ DL("E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64"),
InstrInfo(*this), TLInfo(*this), TSInfo(*this),
FrameLowering(*this, Subtarget) {
initAsmInfo();
void TargetLoweringObjectFile::Initialize(MCContext &ctx,
const TargetMachine &TM) {
Ctx = &ctx;
+ DL = TM.getDataLayout();
InitMCObjectFileInfo(TM.getTargetTriple(),
TM.getRelocationModel(), TM.getCodeModel(), *Ctx);
}
assert(!GV->hasLinkerPrivateLinkage());
assert(!GV->hasLinkerPrivateWeakLinkage());
- const MCAsmInfo *MAI = Ctx->getAsmInfo();
SmallString<60> NameStr;
- NameStr += MAI->getPrivateGlobalPrefix();
+ NameStr += DL->getPrivateGlobalPrefix();
M.getNameWithPrefix(NameStr, GV);
NameStr.append(Suffix.begin(), Suffix.end());
return Ctx->GetOrCreateSymbol(NameStr.str());
void X86MCAsmInfoMicrosoft::anchor() { }
X86MCAsmInfoMicrosoft::X86MCAsmInfoMicrosoft(const Triple &Triple) {
- if (Triple.getArch() == Triple::x86_64) {
- GlobalPrefix = '\0';
+ if (Triple.getArch() == Triple::x86_64)
PrivateGlobalPrefix = ".L";
- HasMicrosoftFastStdCallMangling = false;
- }
AssemblerDialect = AsmWriterFlavor;
void X86MCAsmInfoGNUCOFF::anchor() { }
X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple &Triple) {
- if (Triple.getArch() == Triple::x86_64) {
- GlobalPrefix = '\0';
+ if (Triple.getArch() == Triple::x86_64)
PrivateGlobalPrefix = ".L";
- HasMicrosoftFastStdCallMangling = false;
- }
AssemblerDialect = AsmWriterFlavor;
/// operand to an MCSymbol.
MCSymbol *X86MCInstLower::
GetSymbolFromOperand(const MachineOperand &MO) const {
+ const DataLayout *DL = TM.getDataLayout();
assert((MO.isGlobal() || MO.isSymbol() || MO.isMBB()) && "Isn't a symbol reference");
SmallString<128> Name;
}
if (!Suffix.empty())
- Name += MAI.getPrivateGlobalPrefix();
+ Name += DL->getPrivateGlobalPrefix();
unsigned PrefixLen = Name.size();
// X86 is little endian
std::string Ret = "e";
+ Ret += DataLayout::getManglingComponent(ST.getTargetTriple());
// X86 and x32 have 32 bit pointers.
if (ST.isTarget64BitILP32() || !ST.is64Bit())
Ret += "-p:32:32";
void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
raw_ostream &O) {
+ const DataLayout *DL = TM.getDataLayout();
const MachineOperand &MO = MI->getOperand(opNum);
switch (MO.getType()) {
case MachineOperand::MO_Register:
O << *getSymbol(MO.getGlobal());
break;
case MachineOperand::MO_ConstantPoolIndex:
- O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
+ O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
<< '_' << MO.getIndex();
break;
case MachineOperand::MO_BlockAddress:
CodeGenOpt::Level OL)
: LLVMTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL),
Subtarget(TT, CPU, FS),
- DL("e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32"),
+ DL("e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32"),
InstrInfo(),
FrameLowering(Subtarget),
TLInfo(*this),