From 645406a3d3405ad0f4b5a0e46a34ae92d9d23bd3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 1 Sep 2010 00:24:35 +0000 Subject: [PATCH] same refactoring as before, this time on the argument side. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112684 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetInfo.cpp | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index e9ce20d3db..389fa110fa 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -1550,7 +1550,8 @@ classifyReturnType(QualType RetTy) const { } // If a high part was specified, merge it together with the low part. It is - // known to pass in the high eightbyte of the result. + // known to pass in the high eightbyte of the result. We do this by forming a + // first class struct aggregate with the high and low part: {low, high} if (HighPart) ResType = llvm::StructType::get(getVMContext(), ResType, HighPart, NULL); @@ -1626,6 +1627,7 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned &neededInt, break; } + const llvm::Type *HighPart = 0; switch (Hi) { // Memory was handled previously, ComplexX87 and X87 should // never occur as hi classes, and X87Up must be preceed by X87, @@ -1638,33 +1640,26 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned &neededInt, case NoClass: break; - case Integer: { + case Integer: ++neededInt; // Pick an 8-byte type based on the preferred type. - const llvm::Type *HiType = - GetINTEGERTypeAtOffset(CGT.ConvertTypeRecursive(Ty), 8, Ty, 8); - - if (Lo == NoClass) // Pass HiType at offset 8 in memory. - return ABIArgInfo::getDirect(HiType, 8); + HighPart = GetINTEGERTypeAtOffset(CGT.ConvertTypeRecursive(Ty), 8, Ty, 8); - ResType = llvm::StructType::get(getVMContext(), ResType, HiType, NULL); + if (Lo == NoClass) // Pass HighPart at offset 8 in memory. + return ABIArgInfo::getDirect(HighPart, 8); break; - } // X87Up generally doesn't occur here (long double is passed in // memory), except in situations involving unions. case X87Up: - case SSE: { - const llvm::Type *HiType = - GetSSETypeAtOffset(CGT.ConvertTypeRecursive(Ty), 8, Ty, 8); + case SSE: + HighPart = GetSSETypeAtOffset(CGT.ConvertTypeRecursive(Ty), 8, Ty, 8); - if (Lo == NoClass) // Pass HiType at offset 8 in memory. - return ABIArgInfo::getDirect(HiType, 8); + if (Lo == NoClass) // Pass HighPart at offset 8 in memory. + return ABIArgInfo::getDirect(HighPart, 8); - ResType = llvm::StructType::get(getVMContext(), ResType, HiType, NULL); ++neededSSE; break; - } // AMD64-ABI 3.2.3p3: Rule 4. If the class is SSEUP, the // eightbyte is passed in the upper half of the last used SSE @@ -1675,6 +1670,12 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned &neededInt, break; } + // If a high part was specified, merge it together with the low part. It is + // known to pass in the high eightbyte of the result. We do this by forming a + // first class struct aggregate with the high and low part: {low, high} + if (HighPart) + ResType = llvm::StructType::get(getVMContext(), ResType, HighPart, NULL); + return ABIArgInfo::getDirect(ResType); } -- 2.40.0