X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetLoweringObjectFile.cpp;h=01139fb20cfbc65a1c3a31c2c6f408bc3231ca26;hb=6eb3e3ce10c5dcd8eb748d3b6d0c16f6163ef987;hp=a0218a83df120d570328bb074dbcbebbf71164a9;hpb=9a925861144fba3497f4b6142cdaa70807e3f1e3;p=oota-llvm.git diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index a0218a83df1..01139fb20cf 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -27,8 +27,10 @@ #include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Target/TargetSubtargetInfo.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -41,11 +43,11 @@ using namespace llvm; void TargetLoweringObjectFile::Initialize(MCContext &ctx, const TargetMachine &TM) { Ctx = &ctx; - DL = TM.getDataLayout(); + DL = TM.getSubtargetImpl()->getDataLayout(); InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(), TM.getCodeModel(), *Ctx); } - + TargetLoweringObjectFile::~TargetLoweringObjectFile() { } @@ -61,7 +63,7 @@ static bool isSuitableForBSS(const GlobalVariable *GV, bool NoZerosInBSS) { return false; // If the global has an explicit section specified, don't put it in BSS. - if (!GV->getSection().empty()) + if (GV->hasSection()) return false; // If -nozero-initialized-in-bss is specified, don't ever use BSS. @@ -99,30 +101,22 @@ static bool IsNullTerminatedString(const Constant *C) { return false; } -/// Return the MCSymbol for the specified global value. This -/// symbol is the main label that is the address of the global. -MCSymbol *TargetLoweringObjectFile::getSymbol(const GlobalValue *GV, - Mangler &M) const { - SmallString<60> NameStr; - M.getNameWithPrefix(NameStr, GV); - return Ctx->GetOrCreateSymbol(NameStr.str()); -} - MCSymbol *TargetLoweringObjectFile::getSymbolWithGlobalValueBase( - const GlobalValue *GV, StringRef Suffix, Mangler &M) const { + const GlobalValue *GV, StringRef Suffix, Mangler &Mang, + const TargetMachine &TM) const { assert(!Suffix.empty()); SmallString<60> NameStr; NameStr += DL->getPrivateGlobalPrefix(); - M.getNameWithPrefix(NameStr, GV); + TM.getNameWithPrefix(NameStr, GV, Mang); NameStr.append(Suffix.begin(), Suffix.end()); return Ctx->GetOrCreateSymbol(NameStr.str()); } -MCSymbol *TargetLoweringObjectFile:: -getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang, - MachineModuleInfo *MMI) const { - return getSymbol(GV, Mang); +MCSymbol *TargetLoweringObjectFile::getCFIPersonalitySymbol( + const GlobalValue *GV, Mangler &Mang, const TargetMachine &TM, + MachineModuleInfo *MMI) const { + return TM.getSymbol(GV, Mang); } void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer, @@ -145,7 +139,7 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, // Early exit - functions should be always in text sections. const GlobalVariable *GVar = dyn_cast(GV); - if (GVar == 0) + if (!GVar) return SectionKind::getText(); // Handle thread-local data first. @@ -206,7 +200,8 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalValue *GV, // Otherwise, just drop it into a mergable constant section. If we have // a section for this size, use it, otherwise use the arbitrary sized // mergable section. - switch (TM.getDataLayout()->getTypeAllocSize(C->getType())) { + switch (TM.getSubtargetImpl()->getDataLayout()->getTypeAllocSize( + C->getType())) { case 4: return SectionKind::getMergeableConst4(); case 8: return SectionKind::getMergeableConst8(); case 16: return SectionKind::getMergeableConst16(); @@ -275,33 +270,19 @@ SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler &Mang, return SelectSectionForGlobal(GV, Kind, Mang, TM); } - -// Lame default implementation. Calculate the section name for global. -const MCSection * -TargetLoweringObjectFile::SelectSectionForGlobal(const GlobalValue *GV, - SectionKind Kind, - Mangler &Mang, - const TargetMachine &TM) const{ - assert(!Kind.isThreadLocal() && "Doesn't support TLS"); - - if (Kind.isText()) - return getTextSection(); - - if (Kind.isBSS() && BSSSection != 0) - return BSSSection; - - if (Kind.isReadOnly() && ReadOnlySection != 0) - return ReadOnlySection; - - return getDataSection(); +bool TargetLoweringObjectFile::isSectionAtomizableBySymbols( + const MCSection &Section) const { + return false; } + /// getSectionForConstant - Given a mergable constant with the /// specified size and relocation information, return a section that it /// should be placed in. const MCSection * -TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const { - if (Kind.isReadOnly() && ReadOnlySection != 0) +TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind, + const Constant *C) const { + if (Kind.isReadOnly() && ReadOnlySection != nullptr) return ReadOnlySection; return DataSection; @@ -312,9 +293,10 @@ TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const { /// handling information. const MCExpr *TargetLoweringObjectFile::getTTypeGlobalReference( const GlobalValue *GV, unsigned Encoding, Mangler &Mang, - MachineModuleInfo *MMI, MCStreamer &Streamer) const { + const TargetMachine &TM, MachineModuleInfo *MMI, + MCStreamer &Streamer) const { const MCSymbolRefExpr *Ref = - MCSymbolRefExpr::Create(getSymbol(GV, Mang), getContext()); + MCSymbolRefExpr::Create(TM.getSymbol(GV, Mang), getContext()); return getTTypeReference(Ref, Encoding, Streamer); }