-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] Use correct int extension flags for C-ABI calls on aarch64 #137105
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
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 |
---|---|---|
|
@@ -784,7 +784,7 @@ struct TargetX86_64Win : public GenericTarget<TargetX86_64Win> { | |
} // namespace | ||
|
||
//===----------------------------------------------------------------------===// | ||
// AArch64 linux target specifics. | ||
// AArch64 target specifics. | ||
//===----------------------------------------------------------------------===// | ||
|
||
namespace { | ||
|
@@ -810,6 +810,34 @@ struct TargetAArch64 : public GenericTarget<TargetAArch64> { | |
return marshal; | ||
} | ||
|
||
CodeGenSpecifics::Marshalling | ||
integerArgumentType(mlir::Location loc, | ||
mlir::IntegerType argTy) const override { | ||
if (argTy.getWidth() < getCIntTypeWidth() && argTy.isSignless()) { | ||
AT::IntegerExtension intExt; | ||
if (argTy.getWidth() == 1) { | ||
// Zero extend for 'i1'. | ||
intExt = AT::IntegerExtension::Zero; | ||
} else { | ||
if (triple.isOSDarwin()) { | ||
// On Darwin, sign extend. The apple developer guide specifies this as | ||
// a divergence from the AArch64PCS: | ||
// https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Pass-arguments-to-functions-correctly | ||
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. Does it talk only about arguments and not return values? 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. The apple dev guide does not mention sign/zero extension of returned integers, as far as I can tell. The aa64pcs explains that register types ought to be handled the same way, whether passed or returned:
Clang does the same sign/zero extension for the return type, which is what I used as my guide. I wouldn't mind if the apple dev guide were updated to explicitly say one way or the other, though. |
||
intExt = AT::IntegerExtension::Sign; | ||
} else { | ||
// On linux, pass directly and do not extend. | ||
intExt = AT::IntegerExtension::None; | ||
} | ||
} | ||
CodeGenSpecifics::Marshalling marshal; | ||
marshal.emplace_back(argTy, AT{/*alignment=*/0, /*byval=*/false, | ||
/*sret=*/false, /*append=*/false, | ||
/*intExt=*/intExt}); | ||
return marshal; | ||
} | ||
return GenericTarget::integerArgumentType(loc, argTy); | ||
} | ||
|
||
CodeGenSpecifics::Marshalling | ||
complexReturnType(mlir::Location loc, mlir::Type eleTy) const override { | ||
CodeGenSpecifics::Marshalling marshal; | ||
|
Uh oh!
There was an error while loading. Please reload this page.