Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Show First 20 Lines • Show All 2,010 Lines • ▼ Show 20 Lines | |||||
MCSection *TargetLoweringObjectFileXCOFF::getSectionForExternalReference( | MCSection *TargetLoweringObjectFileXCOFF::getSectionForExternalReference( | ||||
const GlobalObject *GO, const TargetMachine &TM) const { | const GlobalObject *GO, const TargetMachine &TM) const { | ||||
assert(GO->isDeclarationForLinker() && | assert(GO->isDeclarationForLinker() && | ||||
"Tried to get ER section for a defined global."); | "Tried to get ER section for a defined global."); | ||||
SmallString<128> Name; | SmallString<128> Name; | ||||
getNameWithPrefix(Name, GO, TM); | getNameWithPrefix(Name, GO, TM); | ||||
XCOFF::StorageClass SC = | |||||
TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO); | |||||
// Externals go into a csect of type ER. | // Externals go into a csect of type ER. | ||||
return getContext().getXCOFFSection( | return getContext().getXCOFFSection( | ||||
Name, isa<Function>(GO) ? XCOFF::XMC_DS : XCOFF::XMC_UA, XCOFF::XTY_ER, | Name, isa<Function>(GO) ? XCOFF::XMC_DS : XCOFF::XMC_UA, XCOFF::XTY_ER, | ||||
SC, SectionKind::getMetadata()); | SectionKind::getMetadata()); | ||||
} | } | ||||
MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( | MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( | ||||
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { | const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { | ||||
assert(!TM.getDataSections() && | assert(!TM.getDataSections() && | ||||
"XCOFF unique data sections not yet implemented."); | "XCOFF unique data sections not yet implemented."); | ||||
// Common symbols go into a csect with matching name which will get mapped | // Common symbols go into a csect with matching name which will get mapped | ||||
// into the .bss section. | // into the .bss section. | ||||
if (Kind.isBSSLocal() || Kind.isCommon()) { | if (Kind.isBSSLocal() || Kind.isCommon()) { | ||||
SmallString<128> Name; | SmallString<128> Name; | ||||
getNameWithPrefix(Name, GO, TM); | getNameWithPrefix(Name, GO, TM); | ||||
XCOFF::StorageClass SC = | |||||
TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO); | |||||
return getContext().getXCOFFSection( | return getContext().getXCOFFSection( | ||||
Name, Kind.isBSSLocal() ? XCOFF::XMC_BS : XCOFF::XMC_RW, XCOFF::XTY_CM, | Name, Kind.isBSSLocal() ? XCOFF::XMC_BS : XCOFF::XMC_RW, XCOFF::XTY_CM, | ||||
SC, Kind, /* BeginSymbolName */ nullptr); | Kind, /* BeginSymbolName */ nullptr); | ||||
} | } | ||||
if (Kind.isMergeableCString()) { | if (Kind.isMergeableCString()) { | ||||
Align Alignment = GO->getParent()->getDataLayout().getPreferredAlign( | Align Alignment = GO->getParent()->getDataLayout().getPreferredAlign( | ||||
cast<GlobalVariable>(GO)); | cast<GlobalVariable>(GO)); | ||||
unsigned EntrySize = getEntrySizeForKind(Kind); | unsigned EntrySize = getEntrySizeForKind(Kind); | ||||
std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + "."; | std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + "."; | ||||
SmallString<128> Name; | SmallString<128> Name; | ||||
Name = SizeSpec + utostr(Alignment.value()); | Name = SizeSpec + utostr(Alignment.value()); | ||||
return getContext().getXCOFFSection( | return getContext().getXCOFFSection( | ||||
Name, XCOFF::XMC_RO, XCOFF::XTY_SD, | Name, XCOFF::XMC_RO, XCOFF::XTY_SD, | ||||
TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO), | |||||
Kind, /* BeginSymbolName */ nullptr); | Kind, /* BeginSymbolName */ nullptr); | ||||
} | } | ||||
if (Kind.isText()) { | if (Kind.isText()) { | ||||
if (TM.getFunctionSections()) { | if (TM.getFunctionSections()) { | ||||
return cast<MCSymbolXCOFF>(getFunctionEntryPointSymbol(GO, TM)) | return cast<MCSymbolXCOFF>(getFunctionEntryPointSymbol(GO, TM)) | ||||
->getRepresentedCsect(); | ->getRepresentedCsect(); | ||||
} | } | ||||
Show All 25 Lines | MCSection *TargetLoweringObjectFileXCOFF::getSectionForJumpTable( | ||||
assert (!F.getComdat() && "Comdat not supported on XCOFF."); | assert (!F.getComdat() && "Comdat not supported on XCOFF."); | ||||
//TODO: Enable emiting jump table to unique sections when we support it. | //TODO: Enable emiting jump table to unique sections when we support it. | ||||
return ReadOnlySection; | return ReadOnlySection; | ||||
} | } | ||||
bool TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection( | bool TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection( | ||||
bool UsesLabelDifference, const Function &F) const { | bool UsesLabelDifference, const Function &F) const { | ||||
return false; | return false; | ||||
} | } | ||||
Lint: Pre-merge checks: clang-tidy: error: no viable conversion from 'llvm::XCOFF::StorageClass' to 'llvm::SectionKind'… | |||||
/// Given a mergeable constant with the specified size and relocation | /// Given a mergeable constant with the specified size and relocation | ||||
/// information, return a section that it should be placed in. | /// information, return a section that it should be placed in. | ||||
MCSection *TargetLoweringObjectFileXCOFF::getSectionForConstant( | MCSection *TargetLoweringObjectFileXCOFF::getSectionForConstant( | ||||
const DataLayout &DL, SectionKind Kind, const Constant *C, | const DataLayout &DL, SectionKind Kind, const Constant *C, | ||||
Align &Alignment) const { | Align &Alignment) const { | ||||
//TODO: Enable emiting constant pool to unique sections when we support it. | //TODO: Enable emiting constant pool to unique sections when we support it. | ||||
return ReadOnlySection; | return ReadOnlySection; | ||||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | assert( | ||||
isa_and_nonnull<Function>(cast<GlobalAlias>(Func)->getBaseObject()))) && | isa_and_nonnull<Function>(cast<GlobalAlias>(Func)->getBaseObject()))) && | ||||
"Func must be a function or an alias which has a function as base " | "Func must be a function or an alias which has a function as base " | ||||
"object."); | "object."); | ||||
SmallString<128> NameStr; | SmallString<128> NameStr; | ||||
NameStr.push_back('.'); | NameStr.push_back('.'); | ||||
getNameWithPrefix(NameStr, Func, TM); | getNameWithPrefix(NameStr, Func, TM); | ||||
// When -function-sections is enabled, it's not necessary to emit | // When -function-sections is enabled, it's not necessary to emit | ||||
// function entry point label any more. We will use function entry | // function entry point label any more. We will use function entry | ||||
// point csect instead. For function delcarations, it's okay to continue | // point csect instead. And for function delcarations, the undefined symbols | ||||
comment needs to be update here. jasonliu: comment needs to be update here. | |||||
// using label semantic because undefined symbols gets treated as csect with | // gets treated as csect with XTY_ER property. | ||||
// XTY_ER property anyway. | if ((TM.getFunctionSections() || Func->isDeclaration()) && | ||||
if (TM.getFunctionSections() && !Func->isDeclaration() && | |||||
isa<Function>(Func)) { | isa<Function>(Func)) { | ||||
XCOFF::StorageClass SC = | return cast<MCSectionXCOFF>( | ||||
TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(Func); | getContext().getXCOFFSection( | ||||
return cast<MCSectionXCOFF>(getContext().getXCOFFSection( | NameStr, XCOFF::XMC_PR, | ||||
NameStr, XCOFF::XMC_PR, XCOFF::XTY_SD, SC, | Func->isDeclaration() ? XCOFF::XTY_ER : XCOFF::XTY_SD, | ||||
SectionKind::getText())) | SectionKind::getText())) | ||||
->getQualNameSymbol(); | ->getQualNameSymbol(); | ||||
} | } | ||||
return getContext().getOrCreateSymbol(NameStr); | return getContext().getOrCreateSymbol(NameStr); | ||||
} | } | ||||
MCSection *TargetLoweringObjectFileXCOFF::getSectionForFunctionDescriptor( | MCSection *TargetLoweringObjectFileXCOFF::getSectionForFunctionDescriptor( | ||||
const Function *F, const TargetMachine &TM) const { | const Function *F, const TargetMachine &TM) const { | ||||
SmallString<128> NameStr; | SmallString<128> NameStr; | ||||
getNameWithPrefix(NameStr, F, TM); | getNameWithPrefix(NameStr, F, TM); | ||||
return getContext().getXCOFFSection(NameStr, XCOFF::XMC_DS, XCOFF::XTY_SD, | return getContext().getXCOFFSection(NameStr, XCOFF::XMC_DS, XCOFF::XTY_SD, | ||||
getStorageClassForGlobal(F), | |||||
SectionKind::getData()); | SectionKind::getData()); | ||||
} | } | ||||
MCSection *TargetLoweringObjectFileXCOFF::getSectionForTOCEntry( | MCSection *TargetLoweringObjectFileXCOFF::getSectionForTOCEntry( | ||||
const MCSymbol *Sym) const { | const MCSymbol *Sym) const { | ||||
return getContext().getXCOFFSection( | return getContext().getXCOFFSection( | ||||
cast<MCSymbolXCOFF>(Sym)->getSymbolTableName(), XCOFF::XMC_TC, | cast<MCSymbolXCOFF>(Sym)->getSymbolTableName(), XCOFF::XMC_TC, | ||||
XCOFF::XTY_SD, XCOFF::C_HIDEXT, SectionKind::getData()); | XCOFF::XTY_SD, SectionKind::getData()); | ||||
} | } |
clang-tidy: error: no viable conversion from 'llvm::XCOFF::StorageClass' to 'llvm::SectionKind' [clang-diagnostic-error]
not useful