1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

Add read-only data assembly writing for aix

SUMMARY:
The patch will emit read-only variable assembly code for aix.

Reviewers: daltenty,Xiangling_Liao
Subscribers: rupprecht, seiyai,hiraditya

Differential Revision: https://reviews.llvm.org/D70182
This commit is contained in:
diggerlin 2019-11-15 11:30:19 -05:00
parent 488667300d
commit c1ff3621ab
5 changed files with 20 additions and 1 deletions

View File

@ -22,6 +22,8 @@ StringRef XCOFF::getMappingClassString(XCOFF::StorageMappingClass SMC) {
return "TC0";
case XCOFF::XMC_BS:
return "BS";
case XCOFF::XMC_RO:
return "RO";
default:
report_fatal_error("Unhandled storage-mapping class.");
}

View File

@ -1861,6 +1861,10 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal(
if (Kind.isBSS())
return DataSection;
if (Kind.isReadOnly() && !Kind.isMergeableConst() &&
!Kind.isMergeableCString())
return ReadOnlySection;
report_fatal_error("XCOFF other section types not yet implemented.");
}

View File

@ -777,6 +777,10 @@ void MCObjectFileInfo::initXCOFFMCObjectFileInfo(const Triple &T) {
DataSection = Ctx->getXCOFFSection(
".data", XCOFF::StorageMappingClass::XMC_RW, XCOFF::XTY_SD,
XCOFF::C_HIDEXT, SectionKind::getData());
ReadOnlySection = Ctx->getXCOFFSection(
".rodata", XCOFF::StorageMappingClass::XMC_RO, XCOFF::XTY_SD,
XCOFF::C_HIDEXT, SectionKind::getReadOnly());
}
void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,

View File

@ -27,6 +27,13 @@ void MCSectionXCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
return;
}
if (getKind().isReadOnly()) {
if (getMappingClass() != XCOFF::XMC_RO)
report_fatal_error("Unhandled storage-mapping class for .rodata csect.");
OS << "\t.csect " << QualName->getName() << '\n';
return;
}
if (getKind().isData()) {
switch (getMappingClass()) {
case XCOFF::XMC_RW:

View File

@ -1747,7 +1747,9 @@ void PPCAIXAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
report_fatal_error("COMDAT not yet supported by AIX.");
SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
if (!GVKind.isCommon() && !GVKind.isBSS() && !GVKind.isData())
if ((!GVKind.isCommon() && !GVKind.isBSS() && !GVKind.isData() &&
!GVKind.isReadOnly()) ||
GVKind.isMergeableCString() || GVKind.isMergeableConst())
report_fatal_error("Encountered a global variable kind that is "
"not supported yet.");