summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/AutoUpgrade.cpp
diff options
context:
space:
mode:
authorAmy Huang <akhuang@google.com>2019-09-18 22:15:58 +0000
committerAmy Huang <akhuang@google.com>2019-09-18 22:15:58 +0000
commit68eae4985995f06a8bbfadb9cf420a66cbfbe04a (patch)
tree158931587ca48c37796bb118c489590918548b19 /llvm/lib/IR/AutoUpgrade.cpp
parente40ef12bfad0108024d7d3979565096843bb29a7 (diff)
downloadbcm5719-llvm-68eae4985995f06a8bbfadb9cf420a66cbfbe04a.tar.gz
bcm5719-llvm-68eae4985995f06a8bbfadb9cf420a66cbfbe04a.zip
Add AutoUpgrade function to add new address space datalayout string to existing datalayouts.
Summary: Add function to AutoUpgrade to change the datalayout of old X86 datalayout strings. This adds "-p270:32:32-p271:32:32-p272:64:64" to X86 datalayouts that are otherwise valid and don't already contain it. This also removes the compatibility changes in https://reviews.llvm.org/D66843. Datalayout change in https://reviews.llvm.org/D64931. Reviewers: rnk, echristo Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D67631 llvm-svn: 372267
Diffstat (limited to 'llvm/lib/IR/AutoUpgrade.cpp')
-rw-r--r--llvm/lib/IR/AutoUpgrade.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index e9d49d8a2b5..e692201dce6 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -4113,3 +4113,23 @@ MDNode *llvm::upgradeInstructionLoopAttachment(MDNode &N) {
return MDTuple::get(T->getContext(), Ops);
}
+
+std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
+ std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
+
+ // If X86, and the datalayout matches the expected format, add pointer size
+ // address spaces to the datalayout.
+ Triple::ArchType Arch = Triple(TT).getArch();
+ if ((Arch != llvm::Triple::x86 && Arch != llvm::Triple::x86_64) ||
+ DL.contains(AddrSpaces))
+ return DL;
+
+ SmallVector<StringRef, 4> Groups;
+ Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)");
+ if (!R.match(DL, &Groups))
+ return DL;
+
+ SmallString<1024> Buf;
+ std::string Res = (Groups[1] + AddrSpaces + Groups[3]).toStringRef(Buf).str();
+ return Res;
+}
OpenPOWER on IntegriCloud