-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[X86] Align f128 and i128 to 16 bytes when passing on x86-32 #138092
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 | ||||
---|---|---|---|---|---|---|
|
@@ -374,5 +374,37 @@ static bool CC_X86_64_I128(unsigned &ValNo, MVT &ValVT, MVT &LocVT, | |||||
return true; | ||||||
} | ||||||
|
||||||
/// Special handling for i128 and fp128: on x86-32, i128 and fp128 get legalized | ||||||
/// as four i32s, but fp128 must be passed on the stack with 16-byte alignment. | ||||||
/// Technically only fp128 has a specified ABI, but it makes sense to handle | ||||||
/// i128 the same until we hear differently. | ||||||
static bool CC_X86_32_I128_FP128(unsigned &ValNo, MVT &ValVT, MVT &LocVT, | ||||||
CCValAssign::LocInfo &LocInfo, | ||||||
ISD::ArgFlagsTy &ArgFlags, CCState &State) { | ||||||
assert(ValVT == MVT::i32 && "Should have i32 parts"); | ||||||
SmallVectorImpl<CCValAssign> &PendingMembers = State.getPendingLocs(); | ||||||
PendingMembers.push_back( | ||||||
CCValAssign::getPending(ValNo, ValVT, LocVT, LocInfo)); | ||||||
|
||||||
if (!ArgFlags.isInConsecutiveRegsLast()) | ||||||
return true; | ||||||
|
||||||
unsigned NumRegs = PendingMembers.size(); | ||||||
assert(NumRegs == 4 && "Should have two parts"); | ||||||
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.
Suggested change
Minor nit. 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. Fix in #149386 |
||||||
|
||||||
int64_t Offset = State.AllocateStack(16, Align(16)); | ||||||
PendingMembers[0].convertToMem(Offset); | ||||||
PendingMembers[1].convertToMem(Offset + 4); | ||||||
PendingMembers[2].convertToMem(Offset + 8); | ||||||
PendingMembers[3].convertToMem(Offset + 12); | ||||||
|
||||||
State.addLoc(PendingMembers[0]); | ||||||
State.addLoc(PendingMembers[1]); | ||||||
State.addLoc(PendingMembers[2]); | ||||||
State.addLoc(PendingMembers[3]); | ||||||
PendingMembers.clear(); | ||||||
return true; | ||||||
} | ||||||
|
||||||
// Provides entry points of CC_X86 and RetCC_X86. | ||||||
#include "X86GenCallingConv.inc" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -237,9 +237,18 @@ EVT X86TargetLowering::getSetCCResultType(const DataLayout &DL, | |
bool X86TargetLowering::functionArgumentNeedsConsecutiveRegisters( | ||
Type *Ty, CallingConv::ID CallConv, bool isVarArg, | ||
const DataLayout &DL) const { | ||
// i128 split into i64 needs to be allocated to two consecutive registers, | ||
// or spilled to the stack as a whole. | ||
return Ty->isIntegerTy(128); | ||
// On x86-64 i128 is split into two i64s and needs to be allocated to two | ||
// consecutive registers, or spilled to the stack as a whole. On x86-32 i128 | ||
// is split to four i32s and never actually passed in registers, but we use | ||
// the consecutive register mark to match it in TableGen. | ||
if (Ty->isIntegerTy(128)) | ||
return true; | ||
|
||
// On x86-32, fp128 acts the same as i128. | ||
if (Subtarget.is32Bit() && Ty->isFP128Ty()) | ||
return true; | ||
|
||
return false; | ||
|
||
} | ||
|
||
/// Helper for getByValTypeAlignment to determine | ||
|
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.
Seems like this is an assertion-only variable. In non-assertion builds, this gives unused variable warnings.
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.
It looks like somebody got this already fe1941967267e472