diff options
author | Xing Xue <xingxue@outlook.com> | 2019-11-20 11:01:45 -0500 |
---|---|---|
committer | Xing Xue <xingxue@outlook.com> | 2019-11-20 11:26:49 -0500 |
commit | 5665fc91fe93fa4293eb5aceff4884826d8cecb1 (patch) | |
tree | 6f3ea803eee26d3937a421e95140d5353c3a24e4 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | b5135a86e04761577494c70e7c0057136cc90b5b (diff) | |
download | llvm-5665fc91fe93fa4293eb5aceff4884826d8cecb1.zip llvm-5665fc91fe93fa4293eb5aceff4884826d8cecb1.tar.gz llvm-5665fc91fe93fa4293eb5aceff4884826d8cecb1.tar.bz2 |
[AIX][XCOFF] Add support for generating assembly code for one-byte mergable strings
This patch adds support for generating assembly code for one-byte mergeable strings.
Generating assembly code for multi-byte mergeable strings and the `XCOFF` object code for mergeable strings will be supported later.
Reviewers: hubert.reinterpretcast, jasonliu, daltenty, sfertile, DiggerLin, Xiangling_L
Reviewed by: daltenty
Subscribers: wuzish, nemanjai, hiraditya, kbarton, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70310
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 5d5f77b..34ed476 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1849,6 +1849,24 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( SC, Kind, /* BeginSymbolName */ nullptr); } + if (Kind.isMergeableCString()) { + if (!Kind.isMergeable1ByteCString()) + report_fatal_error("Unhandled multi-byte mergeable string kind."); + + unsigned Align = GO->getParent()->getDataLayout().getPreferredAlignment( + cast<GlobalVariable>(GO)); + + unsigned EntrySize = getEntrySizeForKind(Kind); + std::string SizeSpec = ".rodata.str" + utostr(EntrySize) + "."; + SmallString<128> Name; + Name = SizeSpec + utostr(Align); + + return getContext().getXCOFFSection( + Name, XCOFF::XMC_RO, XCOFF::XTY_SD, + TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO), + Kind, /* BeginSymbolName */ nullptr); + } + if (Kind.isText()) return TextSection; @@ -1861,8 +1879,7 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( if (Kind.isBSS()) return DataSection; - if (Kind.isReadOnly() && !Kind.isMergeableConst() && - !Kind.isMergeableCString()) + if (Kind.isReadOnly() && !Kind.isMergeableConst()) return ReadOnlySection; report_fatal_error("XCOFF other section types not yet implemented."); @@ -1920,6 +1937,7 @@ XCOFF::StorageClass TargetLoweringObjectFileXCOFF::getStorageClassForGlobal( const GlobalObject *GO) { switch (GO->getLinkage()) { case GlobalValue::InternalLinkage: + case GlobalValue::PrivateLinkage: return XCOFF::C_HIDEXT; case GlobalValue::ExternalLinkage: case GlobalValue::CommonLinkage: |