-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[WIP] stdlib: add support for AAPCS64 variadics #12623
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
Conversation
@@ -220,6 +241,7 @@ extension CVaListPointer : CustomDebugStringConvertible { | |||
return value.debugDescription | |||
} | |||
} | |||
#endif |
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.
This #endif
should be up a few lines. The CustomDebugStringConvertible
extension should be valid for all definitions.
…and if it isn't valid, you should add a valid one for the AAPCS version.
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.
The value type is different in all cases. In fact, for the AAPCS64 case, its a tuple, rather than an UnsafeMutablePointer
. So this doesn't apply in all cases.
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.
Saleem and I briefly talked about this at the LLVM dev meeting, and I told him to go ahead without it. I'm not sure we have a good debug description for a struct-based va_list that's any better than just showing the children (the default behavior of String(reflecting:)
).
@@ -201,6 +201,27 @@ extension OpaquePointer : Equatable { | |||
} | |||
|
|||
/// The corresponding Swift type to `va_list` in imported C APIs. | |||
#if arch(arm64) && !(os(macOS) || os(iOS) || os(tvOS) || os(watchOS)) |
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.
Please add a comment here describing this as the AAPCS64 case.
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.
Sure
The AAPCS64 ABI requires that `va_list` be defined as: typedef struct __va_list { void *__stack; /* next stack param */ void *__gr_top; /* end of GP reg save area */ void *__vr_top; /* end of FP/SIMD reg save area */ int __gr_offs; /* offset from __gr_top to next GP register arg */ int __vr_offs; /* offset from __vr_top to next FP register arg */ } va_list; This type does not decay and does not match pointer size. `__stack` points to the register save area. `__gr_top` points to the byte immediately following the GPR save area, which is rounded to a 16-byte boundary. `__vr_top` points to the byte immediately following the FPR save area, which is rounded to a 16-byte boundary. `__gr_offs` contains the `((8 - GRCount) * 8)`, `__vr_offs` contains `((8 - FPCount) * 16)`.
eddf050
to
dc4e4e7
Compare
// TODO compare this against the size of the SwiftType rather than the | ||
// void * type. | ||
if (!IsAAPCS64 && | ||
(ClangTypeSize != ClangCtx.getTypeSize(ClangCtx.VoidPtrTy))) |
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.
@jrose-apple I couldn't see the equivalent of getTypeSize
in the swift ASTContext
, perhaps I missed something? Is there an easy way to address that TODO?
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.
Not really. Swift doesn't bother measuring sizes until IR generation time, and even then you won't be able to do it under certain conditions. I think it's okay to just explicitly leave AAPCS64 out of the impedance check.
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.
Okay, Ill probably move this back into the switch then
#15174 is more complete and supersedes this |
The AAPCS64 ABI requires that
va_list
be defined as:This type does not decay and does not match pointer size.
__stack
points to the register save area.__gr_top
points to thebyte immediately following the GPR save area, which is rounded to a
16-byte boundary.
__vr_top
points to the byte immediately followingthe FPR save area, which is rounded to a 16-byte boundary.
__gr_offs
contains the
((8 - GRCount) * 8)
,__vr_offs
contains((8 - FPCount) * 16)
.Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.
Resolves SR-NNNN.