-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang][aarch64] Add support for the MSVC qualifiers __ptr32, __ptr64, __sptr, __uptr for AArch64 #111879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][aarch64] Add support for the MSVC qualifiers __ptr32, __ptr64, __sptr, __uptr for AArch64 #111879
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5565,11 +5565,24 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) { | |
return Res; | ||
} | ||
|
||
auto AddPtr32Ptr64AddrSpaces = [&DL, &Res]() { | ||
// If the datalayout matches the expected format, add pointer size address | ||
// spaces to the datalayout. | ||
StringRef AddrSpaces{"-p270:32:32-p271:32:32-p272:64:64"}; | ||
if (!DL.contains(AddrSpaces)) { | ||
SmallVector<StringRef, 4> Groups; | ||
Regex R("^([Ee]-m:[a-z](-p:32:32)?)(-.*)$"); | ||
if (R.match(Res, &Groups)) | ||
Res = (Groups[1] + AddrSpaces + Groups[3]).str(); | ||
} | ||
}; | ||
|
||
// AArch64 data layout upgrades. | ||
if (T.isAArch64()) { | ||
// Add "-Fn32" | ||
if (!DL.empty() && !DL.contains("-Fn32")) | ||
Res.append("-Fn32"); | ||
AddPtr32Ptr64AddrSpaces(); | ||
return Res; | ||
} | ||
|
||
|
@@ -5588,15 +5601,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) { | |
if (!T.isX86()) | ||
return Res; | ||
|
||
// If the datalayout matches the expected format, add pointer size address | ||
// spaces to the datalayout. | ||
std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64"; | ||
if (StringRef Ref = Res; !Ref.contains(AddrSpaces)) { | ||
SmallVector<StringRef, 4> Groups; | ||
Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)"); | ||
if (R.match(Res, &Groups)) | ||
Res = (Groups[1] + AddrSpaces + Groups[3]).str(); | ||
} | ||
AddPtr32Ptr64AddrSpaces(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I vaguely recall that the autoupgrade was somewhat painful for x86 usage, but I don't have anything specific, and we're just doing exactly the same stuff. @efriedma-quic are there any lessons learned there that we should keep in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there isn't any existing code using the new address-spaces, autoupgrading like this should work smoothly, I think? Need to make sure the autoupgraded string matches the new string, but otherwise should be fine. (I remember last time we made major changes for x86, the 128-bit integer alignment change, it was sort of tricky, but the issue mostly wasn't the layout string itself.) Having a dedicated address-space for __ptr64 is a little strange, but I guess if that's what we did on x86, there isn't really a reason to deviate. |
||
|
||
// i128 values need to be 16-byte-aligned. LLVM already called into libgcc | ||
// for i128 operations prior to this being reflected in the data layout, and | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need some tests in the backend? I guess most things likely work because we already did most of the work for the aarch64_32 ABI, but I'd like to see some tests that the basics work (load/store/arguments/return values).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backend hasn't been implemented yet - I'll have a follow up PR with the changes and tests.