[llvm] 3dfa975 - Add read-only data assembly writing for aix

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 15 08:32:02 PST 2019


Author: diggerlin
Date: 2019-11-15T11:30:19-05:00
New Revision: 3dfa975fb36fda1d8cff700d4251db330c83bfa3

URL: https://github.com/llvm/llvm-project/commit/3dfa975fb36fda1d8cff700d4251db330c83bfa3
DIFF: https://github.com/llvm/llvm-project/commit/3dfa975fb36fda1d8cff700d4251db330c83bfa3.diff

LOG: 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

Added: 
    

Modified: 
    llvm/lib/BinaryFormat/XCOFF.cpp
    llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    llvm/lib/MC/MCObjectFileInfo.cpp
    llvm/lib/MC/MCSectionXCOFF.cpp
    llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/BinaryFormat/XCOFF.cpp b/llvm/lib/BinaryFormat/XCOFF.cpp
index 6613b6329c13..001b8077cd3d 100644
--- a/llvm/lib/BinaryFormat/XCOFF.cpp
+++ b/llvm/lib/BinaryFormat/XCOFF.cpp
@@ -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.");
   }

diff  --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index f941b98890c9..2dc13e9a250e 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -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.");
 }
 

diff  --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index be195928320d..53a9467041c0 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -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,

diff  --git a/llvm/lib/MC/MCSectionXCOFF.cpp b/llvm/lib/MC/MCSectionXCOFF.cpp
index d00e93228970..f646168d3a4a 100644
--- a/llvm/lib/MC/MCSectionXCOFF.cpp
+++ b/llvm/lib/MC/MCSectionXCOFF.cpp
@@ -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:

diff  --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 6feb5ee3373b..e4b3d4684761 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -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.");
 


        


More information about the llvm-commits mailing list