[llvm] [X86] Fix ABI for passing after i128 (PR #124134)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 24 00:08:11 PST 2025
================
@@ -340,5 +340,41 @@ static bool CC_X86_64_Pointer(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
return false;
}
+/// Special handling for i128: Either allocate the value to two consecutive
+/// i64 registers, or to the stack. Do not partially allocate in registers,
+/// and do not reserve any registers when allocating to the stack.
+static bool CC_X86_64_I128(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
+ CCValAssign::LocInfo &LocInfo,
+ ISD::ArgFlagsTy &ArgFlags, CCState &State) {
+ assert(ValVT == MVT::i64 && "Should have i64 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 == 2 && "Should have two parts");
+
+ MCPhysReg Regs[] = {X86::RDI, X86::RSI, X86::RDX, X86::RCX, X86::R8, X86::R9};
+ ArrayRef<MCPhysReg> Allocated = State.AllocateRegBlock(Regs, NumRegs);
+ if (!Allocated.empty()) {
+ for (const auto &[Pending, Reg] : zip(PendingMembers, Allocated)) {
+ Pending.convertToReg(Reg);
+ State.addLoc(Pending);
+ }
+ } else {
+ int64_t Offset = State.AllocateStack(16, Align(16));
+ for (auto &Pending : PendingMembers) {
+ Pending.convertToMem(Offset);
+ State.addLoc(Pending);
+ Offset += 8;
+ }
----------------
phoebewang wrote:
This is not shown in test case, but I have a concern: would we get two discontinuous i64 due to the alignment?
https://github.com/llvm/llvm-project/pull/124134
More information about the llvm-commits
mailing list